问题
I have an example of creating relationship using Neo4JClient: How to create relationships?. How to view the relationship? I mean if I want to find how many nodes are directly connected to "A", how to do that?
Update
After a little help from @manonthemat, I converted the cypher in C#
var record = client.Cypher
.Match("(A)-[r]->()")
.Return((A, r) => new
{
User = A.As<ExampleNode>(),
NumberOfFriends = r.Count()
}).Results;
Though I am able to get the direct count say 4 for A, I also want to get the names of those e.g. B,C,D,E. How to do so?
回答1:
I understand you question to be "How do I determine the nodes which are connected to A?"
If you only want the nodes, the cypher query should look something like this:
Match A-[r:*]-(X)
Return distinct X
If you also want the relationships try this:
Match A-[r:*]-(X)
Return r, distinct X
Sometimes you may want to limit you search to only a certain kind of relationship, like "KNOWS". In which case try this:
Match A-[r:KNOWS*]-(X)
Return r, distinct X
来源:https://stackoverflow.com/questions/35252922/neo4jclient-how-to-view-the-relationship-direct-reportees