Reputation: 574
Ok,
I'm in C# using .NET Framework 4.7.2. I'm trying to use the Hello World example https://neo4j.com/developer/dotnet/. I've installed the driver w/ "PM Install-Package Neo4j.Driver-4.0" and have a reference in the project for version 4.0.78.1.
For the line
using (var session = _driver.Session())
I'm getting
'IDriver' does not contain a definition for 'Session' and no accessible extension method 'Session' accepting a first argument of type 'IDriver' could be found (are you missing a using directive or an assembly reference?)
using Neo4j.Driver;
using System;
using System.Linq;
namespace ConsoleApp5 {
public class HelloWorldExample : IDisposable
{
private readonly IDriver _driver;
public HelloWorldExample(string uri, string user, string password)
{
_driver = GraphDatabase.Driver(uri, AuthTokens.Basic(user, password));
}
public void PrintGreeting(string message)
{
using (var session = _driver.Session())
{
var greeting = session.WriteTransaction(tx =>
{
var result = tx.Run("CREATE (a:Greeting) " +
"SET a.message = $message " +
"RETURN a.message + ', from node ' + id(a)",
new { message });
return result.Single()[0].As<string>();
});
Console.WriteLine(greeting);
}
}
public void Dispose()
{
_driver?.Dispose();
}
public static void Main()
{
using (var greeter = new HelloWorldExample("bolt://localhost:7687", "neo4j", "password"))
{
greeter.PrintGreeting("hello, world");
}
}
}
}
Clearly I'm missing something simple - but after two hours of searching I'm out of ideas.
Upvotes: 1
Views: 281
Reputation: 9002
For Driver version 4, you need to add Neo4j.Driver.Simple
Nuget package to the project as well. Either via graphic interface, or via command line as PM> Install-Package Neo4j.Driver.Simple
According to Neo4j Driver 4.0 docs, Session()
is an extension on IDriver
interface. And as per Session() doc, it's from:
Assembly: Neo4j.Driver.Simple (in Neo4j.Driver.Simple.dll) Version: 4.0.2
Upvotes: 0