0
votes

i am using neo4jclient for C#.

I would like to return something like:

EXTRACT(ri in RELS(p)| STARTNODE(ri)) as StartNodes,EXTRACT(ri in RELS(p)| ri) as Relations,EXTRACT(ri in RELS(p)| ENDNODE(ri)) as EndNodes

How do i extract on the neo4jclient fluent api ?

P is a path.

1

1 Answers

2
votes

Without knowing your complete query or particular problem/scenario you are trying to address, it is difficult to suggest a complete query but a chained return method containing something like the following might work?

var query = client.Cypher
    .Match("p = [your match statement]")
    .Return(p => new
    {
        StartNodes = Return.As<IEnumerable<Node<Person>>>("extract(ri in rels(p) | startnode(ri))"),
        Relations = Return.As<IEnumerable<RelationshipInstance<Person>>>("extract(ri in rels(p) | ri)"),
        EndNodes = Return.As<IEnumerable<Node<Person>>>("extract(ri in rels(p) | endnode(ri))")
    });

If you don't need the wrapper objects you could simply return IEnumerable<Person>, e,g,

.Return(p => new
{
    StartNodes = Return.As<IEnumerable<Person>>("extract(ri in rels(p) | startnode(ri))"),
    Relations = Return.As<IEnumerable<Person>>("extract(ri in rels(p) | ri)"),
    EndNodes = Return.As<IEnumerable<Person>>("extract(ri in rels(p) | endnode(ri))")
    });

Note that the above code assumes that your are trying to deserialize the response from Neo4j into a POCO object of type Person. You should substitute this for whatever object that you are using.