Last active
November 9, 2016 20:57
-
-
Save tugberkugurlu/5877e9fe087498d86a22b6f0eedbe986 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on: | |
// - Getting Started with Neo4j in .NET with Neo4jClient Library: http://www.tugberkugurlu.com/archive/getting-started-with-neo4j-in--net-with-neo4jclient-library | |
// Other links: | |
// - Neo4j: http://neo4j.com/ | |
// - Neo4j .NET Client: https://github.com/Readify/Neo4jClient | |
// - Cypher query language: http://neo4j.com/developer/cypher-query-language/ | |
public class Agency { public string Name { get; set; } } | |
public class Person { public string Name { get; set; } } | |
public class Movie { public string Name { get; set; } } | |
// initiate the client | |
var client = new GraphClient(new Uri("http://localhost:7474/db/data"), "neo4j", "1234567890"); | |
client.Connect(); | |
// query for 'What are the movies which employed all of its actors from one agency?' | |
var results = client.Cypher | |
.Match("(agency:Agency)-[:ACQUIRED]->(actor:Person)<-[:EMPLOYED]-(movie:Movie)") | |
.Return((agency, actor, movie) => new | |
{ | |
Agency = agency.As<Agency>(), | |
Actor = actor.As<Person>(), | |
Movie = movie.As<Movie>() | |
}).Results; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment