问题
I have a Cypher query likes this:
START n=node:permit_idx(PmtID= "111")
Match n-[:Assinged]->m<-[:Assinged]-p
RETURN p.PmtID, count(m);
I got error when I try to do it using Neo4jClient Cypher Query
var results = graphClient
.Cypher
.Start(new { n = Node.ByIndexLookup("permit_idx", "PmtID", "111") })
.Match("Match n-[:Assigned]->m<-[:Assigned]-p")
.Return((m, p) => new
{
PDPmtID = "p.PmtID",
MCount = "count(m)"
})
.Results;
If only need to return one property or one count, we can use
.Return<int>("count(m)");
But how to return property and count together?
回答1:
.Return((m, p) => new
{
PDPmtID = Return.As<int>("p.PmtID"),
MCount = m.Count()
})
Or, preferred right now:
.Return((m, p) => new
{
Permit = p.As<Permit>(),
MCount = m.Count()
})
回答2:
You need to use the custom text option in your compound Return clause:
.Return((m, p) => new
{
PDPmtID = Return.As<int>("p.PmtID"),
MCount = Return.As<int>("count(m)")
})
(This is based on the documentation for the Neo4jClient)
来源:https://stackoverflow.com/questions/18026808/returning-property-and-count-columns-together-in-neo4jclient-cypher-query