我用neo4j 2.2.1
,我有這樣的代碼:如何使用.Net neo4j客戶端獲取屬性的sum()?
MATCH (n:person)-[r:BUY]->(p:product) WHERE p.name IN ['Bag','Book','Pencil'] RETURN SUM(r.total) AS st, n ORDER BY st DESC LIMIT 1
,我要儘量把這段代碼轉換爲C#,
類:
public class person
{
public string name { get; set; }
}
public class product
{
public string name { get; set; }
}
public class buy
{
public int total { get; set; }
}
這裏是我的查詢
public void search1()
{
var data1 = new[] { Bag, Book, Pencil };
var cypher = client.Cypher
.Match("(n:person)-[r:BUY]->(p:product)")
.Where(" p.name IN {data1}")
.WithParams(new { data1 })
.Return((n, r) => new
{
person1 = n.As<person>(),
buy1 = r.As<buy>(),
})
.OrderByDescending("sum(r.total)").Limit(1); //this is an error
foreach (var result in cypher.Results)
{
result1 = result.person1.name;
total1 = result.buy.total; // I want to get sum(r.total) but I can't
}
}
那麼,我的查詢出了什麼問題,我該如何解決?
非常感謝,這是工作。 –