如何使用neo4jClient获取多列数据 -
对于eq。链接上显示的示例
Cyper query to fetch multiple column collection
上面显示的示例传递了用于集合的事件节点的属性,而不是完整的事件节点。
我正在构建的查询从事件节点中获取了很少的属性,并且从关系中获取了很少的属性。
对于eq。关系属性" registerd_on"需要添加。 那么如何传递多个属性进行收集?
答案 0 :(得分:0)
它不是很好,但是如果你看一下通过做一个集合返回的内容你得到一个数组数组,但是这些数组没有这样的属性,所以你只能真正解析它们为string
。
使用:play movies
数据集作为基础:
var query = gc.Cypher
.Match("(p:Person {name:'Tom Hanks'})-->(m:Movie)")
.With("p, collect([m.title, m.released]) as collection")
.Return((p, collection) => new
{
Person = p.As<Person>(),
Collection = Return.As<IEnumerable<IEnumerable<string>>>("collection")
});
其中Person
是:
public class Person
{
public string name { get; set; }
}
然后您可以像这样访问数据:
foreach (var result in results)
{
Console.WriteLine($"Person: {result.Person.name}");
foreach (var collection in result.Collection)
{
foreach (var item in collection)
{
Console.WriteLine($"\t{item}");
}
}
}
这不好看:/