Question

Let’s consider the structure:

(parent) –[:HAS_CHILD]-> (child) –[:HAS_DOG]-> (dog)

Right now I would use the following cypher query to return a sort of hierarchy:

MATCH (p:Parent) -[:HAS_CHILD]-> (c:Child) -[:HAS_DOG]-> (d: Dog)
WITH p, collect(distinct(c)) as children, d
RETURN p, children, collect(distinct(d))

However, it would be much easier if I could have the same mapping as in the Entity Framework (with a list of Children in the Parent class):

public class Parent
{
    public string Id { get; set; }
    public string Name { get; set; }
    public List<Child> Children { get; set; }
}

public class Child
{
    public string Id { get; set; }
    public string Name { get; set; }
    public List<Dog> Dogs { get; set; }
}

public class Dog
{
    public string Id { get; set; }
    public string Name { get; set; }
}

Is there a way to do so?

Was it helpful?

Solution

Think of Neo4jClient as the equivalent to SqlConnection and SqlCommand in .NET. It provides the language bindings to help you construct queries in a safe and efficient way, then retrieve the results.

It is not an ORM, like say Entity Framework.

Just like how Entity Framework uses SqlConnection, you could build one on top of Neo4jClient if you wanted. Somebody started one of those over here: http://www.nuget.org/packages/Neo4jRepository/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top