Reputation: 496
I'm looking into using Neo4j for a project, but I'm a bit confused when it comes to best practices. I would normally assume that the official C# driver provides a method of parameterizing queries, but I can't see anything in the official documentation.
There is what appears to be an unofficial library for C# located on Github with a recent release only a few days old which supports parameterized queries. However, I also remember seeing a comment stating that it mostly supports version 2.x (although I can't find the page stating this). This library only supports http+https as connection methods, there is no support for Bolt. What effect will this have on performance?
What is the preferred driver/library for Neo4j 3.x using C#?
Upvotes: 2
Views: 1058
Reputation: 6270
Neo4jClient (The community driver) does in it's current state not support Bolt, there is a beta pre-release version (which you can get using Nuget by adding https://www.myget.org/F/cskardon/api/v3/index.json as a source to your Nuget) - I'm reasonably confident with it, but it does need testing.
It Will support Bolt though.
The official driver does support paramaterized queries you just have to code it yourself and when you call session.Run
you pass it in as the second argument.
Something like:
var obj = new Dictionary<string, object> { {"Name", "Chris"}, {"Email", "[email protected]"} }
var paramsObj = new Dictionary<string, object> { { "userParam", obj } };
session.Run("CREATE (n:User {userParam})", paramsObj);
The official driver is supported by Neo4j, the community uses the official driver under the hood for bolt, wrapping up the OGM stuff, so the choice is yours from a Bolt point of view. If you need to use HTTP/HTTPS - you have to use Neo4jClient (which will work with 3.x DBs as well)
Upvotes: 3