Reputation: 43
I want to translate something like
MATCH (s)
WHERE ID(s) = 65110
RETURN s
into C# to use it with the Graph client. My main problem is that I want to get a node by using the internal id of Neo4j, which is absolutely no problem in Cypher but how can I do this in Graph client?
var query = client.Cypher
.Match("(s)")
.Where((Event s) => ID(s) == 65110)
.Return(...);
This was my first approach but of course that does not work. Can you tell me how to use this ID function of Cypher to get a node with a specific internal Neo4j id by using the Graph client for C#?
For explanation, client is a variable, that connects to the Graph Client of Neo4j:
var client = new GraphClient(new Uri("http://localhost:7474/db/data"), "username", "Password");
client.Connect();
Upvotes: 1
Views: 419
Reputation: 6270
I'm using a parameter here, as that's the best way to ensure the query will be compiled and cached, obviously you could just put in the ID. Generally - you want to avoid using the ID
of a Neo4j
item, in fact - I would strongly urge you to add you're own ID field. But! here it is anyhews :)
var query = client.Cypher
.Match("(s)")
.Where("ID(s) = {idParam}")
.WithParam("idParam", 65110)
.Return(s => s.As<Node<string>>());
Upvotes: 1