I'm familiar with the ADO NET data provider for PostgreSQL (Npgsql). Using that driver, my C# code just sends SQL query strings and receives rows of results. I was surprised to find that there seems to be a lot of C# code necessary to issue a query to Neo4j, even though Cypher is concise. Could anyone suggest an up to date tutorial? I don't understand https://neo4j.com/developer/dotnet/#_the_example_project. https://github.com/DotNet4Neo4j/Neo4jClient/wiki/cypher looks a bit more manageable but is not a complete example.
Hey @davideps
I've not used ADO.NET for a while now, but from memory, you have your IDbConnection
, which you then use to create DataTables
which are populated via queries with IDbParameter
objects... The full flow (and naming obviously!) escapes me.
I've used both of the drivers you've picked there, and the reason there is more C# than with the ADO approach is largely down to things like the fundamental differences between a Graph Model and a Table based database.
I've been working on (and it's not complete yet) a project which demonstrates the official Driver vs. the Neo4jClient (and also an extension package for the official driver) here:
It's to show how each connector works - all the actual queries being executed are the same. I've tried to document the code - and there is supposed to be a set of posts about it later on - but I haven't finished - in the sense I've not added tests yet.
I have written about testing the Official driver here: https://xclave.co.uk/2020/10/23/testing-neo4j-driver-4-1-1-part-1/ and here: https://xclave.co.uk/2020/11/02/testing-neo4j-driver-4-1-1-part-2-session-config/ if that helps?
All the best
Chris
Chris, thank you for such a quick and detailed reply. I'm finding MoviesMvcCore/MovieDriverController.cs at main · DotNet4Neo4j/MoviesMvcCore · GitHub helpful. For someone new to Neo4j, is there a reason to choose one client over the other?
-david
Generally, it's what you are most comfortable using - the official driver is faster I would say, but requires more manual conversions etc -
The client uses the driver under the hoods for Bolt, but provides a (depending on you view) nicer way to get objects from it. The reason it's slower is down to the way it parses the objects back from the Driver.
You could use the client and you would still have access to the Driver if you wanted to use it:
((BoltGraphClient)client).Driver
Also - the Neo4j.Driver.Extensions
package might make the Driver a bit easier to use.