Ejemplo n.º 1
0
        public async void TestQueryMultiple()
        {
            var persons = new List <Person>()
            {
                new Person()
                {
                    Age         = 50,
                    DateOfBirth = DateTime.Now.AddYears(-50),
                    Id          = Guid.NewGuid(),
                    Name        = "neo",
                    Salary      = 5400.77,
                },
                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.InsertNodes <Person>(persons);

            IEnumerable <Person> personsResult = await context.QueryMultiple <Person>("MATCH (p:Person) return p");

            await context.ExecuteQuery("MATCH (p:Person) DETACH DELETE p");
        }
Ejemplo n.º 2
0
        public async void TestInsertMultipleQueryGeneric()
        {
            var expectedCountries = new Dictionary <string, Country>()
            {
                { "555", new Country()
                  {
                      CountryID = "555", CountryName = "NOM COUNTRY"
                  } },
                { "556", new Country()
                  {
                      CountryID = "556", CountryName = "NOM COUNTRY2"
                  } },
            };
            var context         = new NeoContext(Driver);
            var resultExecuting = await context.InsertNodes <Country>(expectedCountries.Values);

            var resultCountry = await context.QueryMultiple <Country>("match(n:Country) WHERE n.CountryID IN ['555','556'] return n");

            Assert.True(resultExecuting.QueryType == Neo4j.Driver.QueryType.WriteOnly);
            Assert.True(expectedCountries.Count == resultCountry.Count());
            foreach (var resCountry in resultCountry)
            {
                Assert.True(IsEqual(resCountry, expectedCountries[resCountry.CountryID]));
            }
            await context.ExecuteQuery("MATCH (n:Country) WHERE n.CountryID IN ['555','556'] DETACH DELETE n");
        }
        public async void TestMultipleQuery()
        {
            var expectedDic = new Dictionary <string, Country>()
            {
                { "186", new Country()
                  {
                      CountryID = "186", CountryName = "Russia"
                  } },
                { "216", new Country()
                  {
                      CountryID = "216", CountryName = "United States"
                  } }
            };
            var context = new NeoContext(Driver);
            var result  = await context.QueryMultiple <Country>("match(n:Country) WHERE n.countryID IN ['186','216'] return n");

            Assert.NotNull(result);
            Assert.True(result.Count() == expectedDic.Count);
            foreach (var country in result)
            {
                Assert.True(IsEqual(country, expectedDic[country.CountryID]));
            }
        }