Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-09-2020 04:29 PM
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: https://neo4j.com/docs/driver-manual/current/get-started/#driver-get-started-hello-world-example.
Could anyone help me out with getting this working? I was hoping to use it as a baseline to build my own program.
03-10-2020 03:01 AM
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");
}
}
All the sessions of the conference are now available online