Beispiel #1
0
        public async void TestUpdateNode()
        {
            var personGuid = Guid.NewGuid();
            var person     = new Person()
            {
                Age         = 50,
                DateOfBirth = DateTime.Now.AddYears(-50),
                Id          = personGuid,
                Name        = "neo",
                Salary      = 5400.77,
            };
            IDictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "Id", personGuid }
            };
            var            context         = new NeoContext(Driver);
            IResultSummary resultExecuting = await context.InsertNode <Person>(person);

            person.Age = 55;
            await context.Update <Person>("MATCH (p:Person { Id : $Id} )", parameters, "p", person);

            var resultPerson = await context.QueryDefault <Person>("MATCH (p:Person { Id : $Id} ) return p", parameters);

            Assert.Equal <Person>(person, resultPerson);
            await context.ExecuteQuery("MATCH (p:Person) DETACH DELETE p");
        }
Beispiel #2
0
        public async void TestInsertRelation()
        {
            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);
            await context.InsertNode <Country>(country);

            await context.InsertNode <City>(city);

            var resultRelEx = await context.InsertRelation <EXISTS_IN>(
                "MATCH (n:Country { CountryID: '555' }) " +
                "MATCH (c:City { CityId: '5555' })", "c", "n", new EXISTS_IN());

            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(resultRelEx.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");
        }
Beispiel #3
0
        public async void TestInsertQueryGeneric()
        {
            var expectedCountry = new Country()
            {
                CountryID = "555", CountryName = "NOM COUNTRY"
            };
            var context         = new NeoContext(Driver);
            var resultExecuting = await context.InsertNode <Country>(expectedCountry);

            var resultCountry = await context.QueryDefault <Country>("MATCH (n:Country { CountryID: '555' }) RETURN n");

            Assert.True(resultExecuting.QueryType == Neo4j.Driver.QueryType.WriteOnly);
            Assert.True(IsEqual(expectedCountry, resultCountry));
            await context.ExecuteQuery("MATCH (n:Country { CountryID: '555' }) DETACH DELETE n");
        }
Beispiel #4
0
        public async void TestInsertQuery()
        {
            var person = new Person()
            {
                Age         = 50,
                DateOfBirth = DateTime.Now.AddYears(-50),
                Id          = Guid.NewGuid(),
                Name        = "neo",
                Salary      = 5400.77,
            };
            var            context         = new NeoContext(Driver);
            IResultSummary resultExecuting = await context.InsertNode <Person>(person);

            var resultPerson = await context.QueryDefault <Person>("MATCH (p:Person) RETURN p");

            Assert.True(resultExecuting.QueryType == Neo4j.Driver.QueryType.WriteOnly);
            Assert.Equal <Person>(person, resultPerson);
            await context.ExecuteQuery("MATCH (p:Person { Name : 'neo' }) DETACH DELETE p");
        }