c# - Neo4jClient node ids -


i'm having trouble working out how id work in neo4jclient. want .net model have identifier property, , ideally i'd use neo4j autoincremented id node.

however, no matter case use (id, id, id) in model class, adds field in neo4j (keeping 0 when create new node). when view node in neo4j browser, has <id> auto-incremented, , id field 0 (unless manually set in model in c#).

i want able create new .net model class (which have uninitialised id of 0), once i've created neo4j fluent cypher query, have id newly created node's autoincremented id.

the examples here: https://github.com/readify/neo4jclient/wiki/cypher-examples

show user class of having id this:

public long id { get; set; } 

but in example creating new user ...

var newuser = new user { id = 456, name = "jim" }; graphclient.cypher     .create("(user:user {newuser})")     .withparam("newuser", newuser)     .executewithoutresults(); 

i'm unsure 456 magic number comes in example, want neo4j id, don't know until it's created.

alessandro correct, , shouldn't use node id not maps internal representations. if delete node, create another, may have same id.

now, there times need id, (again not use internal identifier) - maybe in path result or something, , neo4jclient allow it.

be warned, way dragons lie.

neo4jclient poco's, helps translate them , neo4j, example wiki that, example, id have come number of sources, or type, example, quite use guids ids. equally, i've used things snowmaker in past generate ids. if want node id, need wrap poco in node<t> type, so:

client.cypher.match("(n:user)").return(n => n.as<user>()).results; 

gets ienumerable<user> response, whereas:

client.cypher.match("(n:user)").return(n => n.as<node<user>>()).results; 

gets ienumerable<node<user>> response, each instance of node<t> have property - reference neo4j id , - data t / poco bit.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -