var query = "MATCH (n) RETURN n"; var driver = GraphDatabase.Driver("bolt://localhost:7687", AuthTokens.Basic("neo4j", "password")); var session = driver.Session(); var result = session.Run(query); foreach (var record in result) { var node = record["n"].As(); Console.WriteLine($"Node: {node.Id} - {node.Labels.First()}"); }
var query = "MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'}) CREATE (a)-[:FRIENDS]->(b)"; var driver = GraphDatabase.Driver("bolt://localhost:7687", AuthTokens.Basic("neo4j", "password")); var session = driver.Session(); session.Run(query);In this example, we are creating a relationship between two nodes in a Neo4j database using a Cypher query. The query specifies that we want to match nodes with the names "Alice" and "Bob" and create a "FRIENDS" relationship between them. Package library: Neo4j.Driver.