It seems like the published Hello World Example does not work with the most recent version of the .NET driver - when I put this code into Visual Studio after downloading the most recent version from nuGet, it has errors: Neo4j documentation - Neo4j Documentation.
Could anyone help me out with getting this working? I was hoping to use it as a baseline to build my own program.
The example will work if you use the Neo4j.Driver.Simple
nuget package - once you've got used to that you can switch to the async
version if you want, which would be something like this:
public class HelloWorldExample
{
private readonly IDriver _driver;
public HelloWorldExample(string uri, string user, string password)
{
_driver = GraphDatabase.Driver(uri, AuthTokens.Basic(user, password));
}
public async Task PrintGreeting(string message)
{
var session = _driver.AsyncSession();
var greeting = session.WriteTransactionAsync(async tx =>
{
var result = await tx.RunAsync("CREATE (a:Greeting) " +
"SET a.message = $message " +
"RETURN a.message + ', from node ' + id(a)",
new { message });
return (await result.SingleAsync())[0].As<string>();
});
Console.WriteLine(greeting);
await session.CloseAsync();
}
public static async Task Main()
{
var greeter = new HelloWorldExample("bolt://localhost:7687", "neo4j", "neo");
await greeter.PrintGreeting("hello, world");
}
}