Example #1
0
        public void RunCustomCypherWithReturnsQuery()
        {
            using (var client = new NeoClient(URL, USER, PASSWORD, CONFIG))
            {
                client.Connect();

                string cypherCreateQuery = @"CREATE (Neo:Crew {name:'Neo'}), 
                (Morpheus:Crew {name: 'Morpheus'}), 
                (Trinity:Crew {name: 'Trinity'}), 
                (Cypher:Crew:Matrix {name: 'Cypher'}), 
                (Smith:Matrix {name: 'Agent Smith'}), 
                (Architect:Matrix {name:'The Architect'}),
                (Neo)-[:KNOWS]->(Morpheus), 
                (Neo)-[:LOVES]->(Trinity), 
                (Morpheus)-[:KNOWS]->(Trinity),
                (Morpheus)-[:KNOWS]->(Cypher), 
                (Cypher)-[:KNOWS]->(Smith), 
                (Smith)-[:CODED_BY]->(Architect)";

                IStatementResult createResult = client.RunCustomQuery(
                    query: cypherCreateQuery
                    );

                string cypherQuery = @"match (n:Crew)-[r:KNOWS*]-(m) where n.name='Neo' return n as Neo,r,m";

                IStatementResult queryResult = client.RunCustomQuery(
                    query: cypherQuery
                    );

                IList <object> result = queryResult.GetValues();

                createResult.Should().NotBeNull();
                createResult.Summary.Counters.LabelsAdded.Should().Be(7);
                createResult.Summary.Counters.NodesCreated.Should().Be(6);
                createResult.Summary.Counters.PropertiesSet.Should().Be(6);
                createResult.Summary.Counters.RelationshipsCreated.Should().Be(6);
                queryResult.Should().NotBeNull();
                result.Should().NotBeNullOrEmpty();
            }
        }