@@ -9,43 +9,12 @@ link:https://www.nuget.org/packages/Neo4j.Driver/.
9
9
10
10
[source, csharp, role=nocollapse]
11
11
----
12
- public class HelloWorldExample : IDisposable
13
- {
14
- private readonly IDriver _driver;
12
+ using Neo4j.Driver;
15
13
16
- public HelloWorldExample(string uri, string user, string password)
17
- {
18
- _driver = GraphDatabase.Driver(uri, AuthTokens.Basic(user, password));
19
- }
14
+ const string uri = "{neo4j-database-uri}";
15
+ const string user = "<Username>";
16
+ const string password = "<Password>";
20
17
21
- public void PrintGreeting(string message)
22
- {
23
- using var session = _driver.Session();
24
- var greeting = session.ExecuteWrite(
25
- tx =>
26
- {
27
- var result = tx.Run(
28
- "CREATE (a:Greeting) " +
29
- "SET a.message = $message " +
30
- "RETURN a.message + ', from node ' + id(a)",
31
- new { message });
32
-
33
- return result.Single()[0].As<string>();
34
- });
35
-
36
- Console.WriteLine(greeting);
37
- }
38
-
39
- public void Dispose()
40
- {
41
- _driver?.Dispose();
42
- }
43
-
44
- public static void Main()
45
- {
46
- using var greeter = new HelloWorldExample("{neo4j-database-uri}", "<Username>", "<Password>");
47
-
48
- greeter.PrintGreeting("hello, world");
49
- }
50
- }
18
+ await using var driver = GraphDatabase.Driver(uri, AuthTokens.Basic(user, password));
19
+ await driver.VerifyConnectivityAsync();
51
20
----
0 commit comments