Any way to concatenates multiple sequence of cypherfluentquery

11 views
Skip to first unread message

Hemant Athavale

unread,
Jun 28, 2018, 8:24:19 PM6/28/18
to Neo4jClient
Hi!

Is there any way to concatenates multiple sequences of cypherfluentquery?

Thanks
Hemant

Chris Skardon

unread,
Jun 29, 2018, 3:57:12 AM6/29/18
to neo4j...@googlegroups.com
Hi Hemant,

What exactly do you want to do? Can you give a code example of what you'd like to see?

All the best

Chris

--
You received this message because you are subscribed to the Google Groups "Neo4jClient" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4jclient...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hemant Athavale

unread,
Jun 29, 2018, 9:27:43 AM6/29/18
to neo4j...@googlegroups.com
graphclient.cypher returns ICypherFluentQuery. which can be executed separately at the end. 
e.g. we have a person and department. each has separate classes and methods to upsert which returns the only query (ICypherFluentQuery). 
In another method where we need to upsert together, we can call individual query methods from its own class and concatenate and execute. 
Trying to reduce duplicate code. (like we can concatenate IQueryable)

Thanks
Hemant

Chris Skardon

unread,
Jun 29, 2018, 11:38:37 AM6/29/18
to neo4j...@googlegroups.com

There’s no reason you can’t just chain the calls together:

 

public ICypherFluentQuery GetUserMatch(ICypherFluentQuery query, string name){

                return  query.Match(“(u:User {name:’” + name + ”’})”);

}

 

Public ICypherFluentQuery GetLocationMatch(ICypherFluentQuery query, string location){

                return query.Match(“(l:Location {name:’” + location + “’})”);

}

 

Then something like:

 

Var query = GetUserMatch(gc.Cypher, “chris”);

query = GetLocationMatch(query, “England”);

 

Is that what you’re talking about?

Hemant Athavale

unread,
Jun 29, 2018, 12:00:18 PM6/29/18
to neo4j...@googlegroups.com
Yes sir, thanks.

Hemant Athavale

unread,
Jun 29, 2018, 1:01:37 PM6/29/18
to neo4j...@googlegroups.com
I have 1 mode question on return
have class Person and addresses

can i return object from query like this
{
         firstname: "some name",
         lastname: "last name",
         addresses : [
                {city : "Bedford",
                 xxxx
                },
                {
                     city: "Edison",
                }
         ]
}

Chris Skardon

unread,
Jul 2, 2018, 3:14:06 AM7/2/18
to neo4j...@googlegroups.com
Not directly no, as you are returning an array of complex types, you would need to use a JsonConverter if that's how it's stored in the DB, or return something like:

class UserAndAddresses {
   User User {get;set;}
   IEnumerable<Address> Addresses {get;set;}
}

...
.Return( (u,a) => return new UserAndAddresses {
    User = u.As<User>()
    Addresses = a.CollectAs<Address>()
})

Largely depends on your cypher and node setup
Reply all
Reply to author
Forward
0 new messages