-
Notifications
You must be signed in to change notification settings - Fork 6
/
Example.cs
38 lines (32 loc) · 1.06 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 (t:Tag {name:$tagName})<-[:TAGGED]-(q:Question)<-[:ANSWERED]-(a:Answer {is_accepted:true})<-[:PROVIDED]-(u:User)
RETURN u.display_name as answerer LIMIT 5
";
var session = driver.AsyncSession(o => o.WithDatabase("neo4j"));
var result = await session.ReadTransactionAsync(async tx => {
var r = await tx.RunAsync(cypherQuery,
new { tagName="neo4j"});
return await r.ToListAsync();
});
await session?.CloseAsync();
foreach (var row in result)
Console.WriteLine(row["answerer"].As<string>());
}
}
}