【发布时间】:2021-11-10 11:44:20
【问题描述】:
我正在尝试将在 Neo4j 图形界面中工作的特定查询转换为使用 C# 中的 Neo4jClient 的实现。
我想在一个列表中获取结果节点的所有关系类型。这可以使用以下查询:
MATCH ()-[relations]-(p)
Where p.name = 'example'
RETURN count(relations) AS relCount, collect(type(relations)) as types limit 10
这会导致
| relCount | types |
|---|---|
| 4 | ["died_in", "has_type", "was_born", "is_identified_by"] |
| 2 | ["has_type", "is_identified_by"] |
在 C# 中使用客户端时,我无法同时使用 relations.type() 和 relations.CollectAs<List<string>>()。
var q = client.Cypher
.Match(@"()-[relations]-(p)")
.Where("p.name = 'example'")
.Return((relations, p) => new
{
relCount = relations.Count(),
types = relations.CollectAs<List<string>>(),
});
所以最后我想要一个这样的对象:
[
{
relcount: 4,
types: ["died_in", "has_type", "was_born", "is_identified_by"]
},
{
relcount: 2,
types: ["has_type", "is_identified_by"]
}
]
有人能给我指出正确的方向吗?
【问题讨论】:
标签: c# neo4j neo4jclient