Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Create a Node with Neo4jClient in Neo4j v2?
    text
    copied!<p>Under Neo4j v1.9.x, I used the following sort of code. </p> <pre><code>private Category CreateNodeCategory(Category cat) { var node = client.Create(cat, new IRelationshipAllowingParticipantNode&lt;Category&gt;[0], new[] { new IndexEntry(NeoConst.IDX_Category) { { NeoConst.PRP_Name, cat.Name }, { NeoConst.PRP_Guid, cat.Nguid.ToString() } } }); cat.Nid = node.Id; client.Update&lt;Category&gt;(node, cat); return cat; } </code></pre> <p>The reason being that the Node Id was auto generated and I could use it later for a quick look up, start bits in other queries, etc. Like the following:</p> <pre><code> private Node&lt;Category&gt; CategoryGet(long nodeId) { return client.Get&lt;Category&gt;((NodeReference&lt;Category&gt;)nodeId); } </code></pre> <p>This enables the following which appeared to work well.</p> <pre><code> public Category CategoryAdd(Category cat) { cat = CategoryFind(cat); if (cat.Nid != 0) { return cat; } return CreateNodeCategory(cat); } public Category CategoryFind(Category cat) { if (cat.Nid != 0) { return cat; } var node = client.Cypher.Start(new { n = Node.ByIndexLookup(NeoConst.IDX_Category, NeoConst.PRP_Name, cat.Name)}) .Return&lt;Node&lt;Category&gt;&gt;("n") .Results.FirstOrDefault(); if (node != null) { cat = node.Data; } return cat; } </code></pre> <p>Now the cypher Wiki, examples and bad-habits recommend using the .ExecuteWithoutResults() in all the CRUD.</p> <p>So the question I have is how do you have an Auto Increment value for the node ID?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload