Transaction support will ship with Neo4j 2.0 and later Neo4jClient. This issue is tracking work: https://bitbucket.org/Readify/neo4jclient/issue/91/support-cypher-transactions-integrated
It does not give you uniqueness, though ...
Neo4j does not have unique indexes - this is something to automatically provide this idea. (I expect that we will see this with Neo4j 2.0 labels in the future, but not yet.)
You need to either a) know that what you are creating is unique, or b) check first.
It seems you take route B.
Transactions allow you to verify and then create as part of a single transactional action, but still several calls through the wire.
The Cypher text you wrote out is actually preferable: you check and create in one statement. I am intrigued to understand why you think this is hacking.
You can execute this expression through Neo4jClient with something like:
var id = 123; graphClient.Cypher .Start(new { n = Node.ByIndexLookup("node_auto_index", "name", id)}) .With("count(*) as c") .Where("c=0") .Create("x={0}", new MyType { name = id }) .Return<Node<MyType>>("c")
Some of the With and Where statements would be nice if they were cleaner, but now they are functional.
There is also a Cypher CREATE UNIQUE clause that may also cover your scenario.
source share