Search code examples
graphneo4jgremlinneo4jclient

How can I load a vertex with related vertex as a collection


GraphDb side

Vertex:User

Edge:Has

Vertex:Car

Object Side

public class User {  
    public string Name { get; set; }

    [GraphEdge("HAS_CAR")]
    public ICollection<Car> Cars { get; set; }
}

Problem

I want to get User X with Cars property from Neo4J via Gremlin? (I'm using Neo4jClient)

It's so similar Include method of Linq to Entity..

Best regards


Solution

  • Oğuz,

    Now that you have updated the question, I understand it better.

    GraphEdgeAttribute is not part of Neo4jClient, so I'm not sure where it has come from.

    In Neo4jClient, we do not load deep objects. That is, we will not follow properties and load further collections. We do this because a) it would require us to do lots of roundtrips to the server and b) we think you should be explicit about what data you actually want to load. We do not want to be an equivalent to the Spring Data for Neo4j project because I do not believe it is a good approach.

    It sounds like you might want to look at Cypher instead of Gremlin. That will let you load data as tables, including projections from multiple nodes.

    -- Tatham