-
Notifications
You must be signed in to change notification settings - Fork 4
/
Example.cs
38 lines (32 loc) · 1.04 KB
/
Example.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// install dotnet core on your system
// dotnet new console -o .
// dotnet add package Neo4j.Driver
// paste in this code into Program.cs
// dotnet run
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Neo4j.Driver;
namespace dotnet {
class Example {
static async Task Main() {
var driver = GraphDatabase.Driver("bolt://<HOST>:<BOLTPORT>",
AuthTokens.Basic("<USERNAME>", "<PASSWORD>"));
var cypherQuery =
@"
MATCH (a:Officer {name: $name})-[r:OFFICER_OF|INTERMEDIARY_OF|REGISTERED_ADDRESS*..5]-(b)
RETURN distinct b.name as name LIMIT 20
";
var session = driver.AsyncSession(o => o.WithDatabase("neo4j"));
var result = await session.ReadTransactionAsync(async tx => {
var r = await tx.RunAsync(cypherQuery,
new { name="Stuart Onslow-Smith"});
return await r.ToListAsync();
});
await session?.CloseAsync();
foreach (var row in result)
Console.WriteLine(row["name"].As<string>());
}
}
}