Search code examples
neo4jclient

Is it possible to define Type, Labels and Id of Node and Relationship with Neo4Jclient?


In a browser I can do some command with Cypher to define a Type, Label and Id of Nodes and Relationships like:

    MATCH (a)-[r]-(b) RETURN Id(a), Labels(a), Type(r), a    

Are there ways to do this in Neo4jclient?


Solution

  • Your question shows querying this information, not defining it.

    You can write an equivalent query with Neo4jClient like so:

    graphClient.Cypher
        .Match("(a)-[r]-(b)")
        .Return(a => new {
            Id = a.Id(),
            Labels = a.Labels(),
            Type = r.Type()
        })
    

    Functions are documented here: https://github.com/Readify/Neo4jClient/wiki/cypher#using-functions-in-return-clauses