private int ReadInt(string database, string query) { using (var session = _driver.Session(SessionConfigBuilder.ForDatabase(database))) { return(ValueExtensions.As <int>(session.Run(query).Single()[0])); } }
public List <string> GetPeople() { using (var session = _driver.Session()) { return(session.ReadTransaction(tx => { var result = tx.Run("MATCH (a:Person) RETURN a.name ORDER BY a.name"); return result.Select(record => ValueExtensions.As <string>(record[0])).ToList();// .As<string>()) })); } }
public int AddEmployees(string companyName) { using (var session = _driver.Session()) { var persons = session.ReadTransaction(tx => tx.Run("MATCH (a:Person) RETURN a.name AS name").ToList()); return(persons.Sum(person => session.WriteTransaction(tx => { tx.Run("MATCH (emp:Person {name: $person_name}) " + "MERGE (com:Company {name: $company_name}) " + "MERGE (emp)-[:WORKS_FOR]->(com)", new { person_name = ValueExtensions.As <string>(person["name"]), company_name = companyName }); return 1; }))); } }
public void PrintGreeting(string message) { using (var session = _driver.Session()) { var greeting = session.WriteTransaction(tx => { string sql = "CREATE (a:Greeting) " + "SET a.message = 'message' " + "RETURN a.message + ', from node ' + id(a)"; var result = tx.Run(sql); //var result = tx.Run("CREATE (a:Greeting) " + // "SET a.message = $message " + // "RETURN a.message + ', from node ' + id(a)", // new { message }); return(ValueExtensions.As <string>(result.Single()[0])); //result.Single()[0].As<string>(); }); Console.WriteLine(greeting); } }