Reputation: 754
I'm following this guide here to help me get started in writing a simple query to retrieve some nodes I have established in a local database.
The NuGet package I'm using says 4.0.0, and the documentation is 1.7. I'm not sure if the 4.0.0 is the server version of Neo4J or the .NET API version.
This block here:
public void GetMedicalDevices () {
string query = "match (n:MedicalDevices) return n";
using (var session = _driver.Session()) {
var data = session.WriteTransaction(tx =>
{
var result = tx.Run( query );
return result;
});
}
}
At _driver.Session()
is where this error is happening I can't figure out.
CS1061 '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?)
I'm not sure what other references I'm missing if any, or if maybe the documentation I'm reading is out of data and Session()
actually doesn't exist on "IDriver" anymore.
Here's the whole class I'm using to write some foobar code to see some things working.
class HelloBoltDriver : IDisposable {
private readonly IDriver _driver;
public HelloBoltDriver (string uri, string user, string password) {
try {
_driver = GraphDatabase.Driver(uri, AuthTokens.Basic(user, password));
} catch (Exception e) {
Debug.Log(e.Message);
}
}
public void GetMedicalDevices () {
string query = "match (n:MedicalDevices) return n";
using (var session = _driver.Session()) {
var data = session.WriteTransaction(tx =>
{
var result = tx.Run( query );
return result;
});
}
}
public void Dispose () {
_driver?.Dispose();
}
}
Upvotes: 4
Views: 1206
Reputation: 21
Explanation of Simple Session as an extension to the main driver is here
You need to install the Neo4j.Driver.Simple package
Upvotes: 2
Reputation:
Try to use something like:
private async Task mnu_ClickAsync(object sender, RoutedEventArgs e)
{
IDriver driver = GraphDatabase.Driver("neo4j://localhost:7687", AuthTokens.Basic("username", "pasSW0rd"));
IAsyncSession session = driver.AsyncSession(o => o.WithDatabase("neo4j"));
try
{
IResultCursor cursor = await session.RunAsync("CREATE (n) RETURN n");
await cursor.ConsumeAsync();
}
finally
{
await session.CloseAsync();
}
await driver.CloseAsync();
Upvotes: 1