I'm having trouble working out how the ID work in Neo4jClient. I want my .NET model to have an identifier property, and ideally I'd like it just to use the Neo4j autoincremented id for that node.
However, no matter what case I use (id
, ID
, Id
) in my model class, it always adds this as another field in Neo4j (keeping it as 0 when I create a new node). So when I view that node in the Neo4j browser, it has a <id>
which is auto-incremented, and also my id
field which is always 0 (unless I manually set it in my model in C#).
I want to be able to create a new .NET model class (which will initially have an uninitialised id of 0), then once I've created it with the Neo4j fluent Cypher query, it will have the ID from the newly created node's autoincremented ID.
The examples here: https://github.com/Readify/Neo4jClient/wiki/cypher-examples
Show their User
class of having an ID like this:
public long Id { get; set; }
But in the example for creating a new User ...
var newUser = new User { Id = 456, Name = "Jim" };
graphClient.Cypher
.Create("(user:User {newUser})")
.WithParam("newUser", newUser)
.ExecuteWithoutResults();
I'm unsure where this 456
magic number comes from in this example, but I just want this to be the Neo4j id, which I obviously don't know until it's created.