Skip to content

Instantly share code, notes, and snippets.

@tugberkugurlu
Last active November 9, 2016 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tugberkugurlu/5877e9fe087498d86a22b6f0eedbe986 to your computer and use it in GitHub Desktop.
Save tugberkugurlu/5877e9fe087498d86a22b6f0eedbe986 to your computer and use it in GitHub Desktop.
// 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