Exemplo n.º 1
0
        public async void TestInsertQueryParameters()
        {
            var personGuid = Guid.NewGuid();
            var person     = new Person()
            {
                Age         = 50,
                DateOfBirth = DateTime.Now.AddYears(-50),
                Id          = personGuid,
                Name        = "neo",
                Salary      = 5400.77,
            };
            var context    = new NeoContext(Driver);
            var parameters = new Dictionary <string, object>();

            parameters.Add("p1", "neo");
            parameters.Add("p2", personGuid);
            parameters.Add("p3", person.DateOfBirth);
            parameters.Add("p4", person.Salary);
            var resultExecuting = await context.Insert("CREATE (:Person {  Name : $p1 , Id: $p2, DateOfBirth: $p3 , Salary: $p4 })", parameters);

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

            Assert.True(resultExecuting.QueryType == Neo4j.Driver.QueryType.WriteOnly);
            Assert.True(person.Id == resultPerson.Id);
            await context.ExecuteQuery("MATCH (p:Person) DETACH DELETE p");
        }