How should I proceed when I have an existing graph?
Hatzman91 opened this issue · comments
Not actually an "Issue", but:
I already use a graph with the Gremlin, just with the standart GremllinServer and string query.
I tried to read my Vertexes with Gremlinq but it just doesn't find my pre-existing Vertexes.
When I Create a new one with the Gremlinq and then read it, it works perfectly.
What do I have to look out for, so the Gremlinq recognizes my objects?
Should usually work out of the box. What does a call to g.V() yield for you ?
Ahhh
I got it now, I had a casesensitive problem with the Label, now i get what I want :)
But with this I could use some help:
I want to re-create this query:
g.V('{userInput}')
// Topic
.project('Id','Label','Message','DisplayText','ImageUrl','YesNoQuestion','GetGrandchildren','ChildTopics') .by('id')
.by('label')
.by('message')
.by('displayText')
.by('imageUrl')
.by('yesNoQuestion')
.by('getGrandchildren')
.by(outE('parentOf')
.project('Id','SortId','AnswerOption','Message','DisplayText','ImageUrl','ChildTopics')
.by(inV().id())
.by('sortId')
.by('answerOption')
.by(inV().values('message'))
.by(inV().values('displayText'))
.by(inV().values('imageUrl'))
.by(inV().outE()
.project('Id','SortId','AnswerOption','Message','DisplayText','ImageUrl')
.by(inV().id())
.by('sortId')
.by('answerOption')
.by(inV().values('message'))
.by(inV().values('displayText'))
.by(inV().values('imageUrl'))
.fold())
.fold())
I have 2 Objects which look like this:
Topic:
public string Id { get; set; }
public string Message { get; set; }
public string DisplayText { get; set; }
public List ChildTopics { get; set; }
public string ImageUrl { get; set; }
public bool YesNoQuestion { get; set; }
public bool GetGrandchildren { get; set; }
And
ChildTopic
public string Id { get; set; }
public string Message { get; set; }
public string DisplayText { get; set; }
public List ChildTopics { get; set; }
public string AnswerOption { get; set; }
public string ImageUrl { get; set; }
public int SortId { get; set; }
And in the Graph i have "Topic" Verteces which are Connected as "ParentOf" with properties
ParentOf:
public string AnswerOption { get; set; }
public int SortId { get; set; }
I want to get 1 selected Topic and all of its children, and it's childrens-children
any help how to project these connections in my objects would be appreciated :)
The support for project in Gremlinq is currently limited to projecting to ValueTuples only, i.e. project in Gremlinq won't give you any POCOs.
Please rework your query to be a bit more readable, and maybe trim it down, I might be able to give you some working Gremlinq query that you can use to go from there.
I updated my comment
I think when I somehow could get a touple with ParentTopic-Vertex, ParentOf-Edge and ChildTopic-Vertex I could work very well with that
What about something like
g
.V(userInput)
.OfType<ParentTopic>()
.OutE<ParentOf>()
.Where(_ => _.InV().OfType<ChildTopic>())
.Project(
_ => _.OutV(),
_ => _,
_ => _.InV().OfType<ChildTopic>())
Would that work ?
Or to get a nicer structure with less redundancy:
g
.V(userInput)
.OfType<ParentTopic>()
.Project(
_ => _
_ => _
.OutE<ParentOf>()
.Where(_ => _.InV().OfType<ChildTopic>())
.Project(
_ => _,
_ => _..InV().OfType<ChildTopic>())
.Fold())
Thank you very much, got it working with the second call!