public async void TestInsertNodesWithRelationGeneric() { var country = new Country() { CountryID = "555", CountryName = "NOM COUNTRY" }; var city = new City() { CityId = "5555", CityName = "NOM CITY" }; country.Cities = new List <City>() { city }; var context = new NeoContext(Driver); var resultExecuting = await context.InsertNodeWithRelation <City, EXISTS_IN, Country>(city, new EXISTS_IN(), country); var resultCountry = await context.QueryDefaultIncludeable <Country, City>("MATCH (n:Country { CountryID: '555' })<-[e:EXISTS_IN]-(c:City) return n,c", (country, city) => { country.Cities = new List <City>() { city }; return(country); } ); Assert.True(resultExecuting.QueryType == Neo4j.Driver.QueryType.WriteOnly); Assert.True(IsEqual(country, resultCountry)); await context.ExecuteQuery("MATCH (n:Country { CountryID: '555' }) DETACH DELETE n"); await context.ExecuteQuery("MATCH (n:City { CityId: '5555' }) DETACH DELETE n"); }
public async void TestInsertNodesWithRelation() { var person = new Person() { Age = 50, DateOfBirth = DateTime.Now.AddYears(-50), Id = Guid.NewGuid(), Name = "neo", Salary = 5400.77, Owns = new List <Owns>() { new Owns() { OwnedFrom = DateTime.Now.AddYears(-2), OwnedTill = DateTime.Now.AddYears(-1), House = new House() { Address = "test address", Age = 150 } } } }; INeoContext context = new NeoContext(Driver); IResultSummary resultExecuting = await context.InsertNodeWithRelation <Person, Owns, House>(person, person.Owns.First(), person.Owns.First().House); Dictionary <Guid, Person> personContainer = new Dictionary <Guid, Person>(); var resultPerson = await context.QueryDefaultIncludeable <Person, Owns, House>("MATCH (p:Person { Name: 'neo' })-[o:Owns]->(h:House) return p,o,h", (p, o, h) => { if (!personContainer.ContainsKey(p.Id)) { personContainer.Add(p.Id, p); p.Owns = new List <Owns>(); } personContainer[p.Id].Owns.Add(o); o.House = h; return(personContainer[p.Id]); } ); await context.ExecuteQuery("MATCH (n:Person { Name: 'neo' }) DETACH DELETE n"); await context.ExecuteQuery("MATCH (p:House {Address: 'test address'}) DETACH DELETE p"); Assert.Equal <Person>(person, resultPerson); }