neo4jclient:我们如何在一次查询中 return 节点标签和属性?
neo4jclient: how do we return node label and properties in one query?
var pubs = client.Cypher
.Match("(s)")
.Where("s:APublisher OR s:BPublisher OR s:CPublisher OR s:DPublisher ")
.Return(s => s.As<Publisher>())
.Results.ToList<Publisher>();
通过上述查询,返回节点的所有属性并为每个节点创建 "Publisher" 个对象。
如何获取节点标签,并将其设置为新创建的 "Publisher" 对象的 "Labels" 属性?
谢谢..
您需要使用适当的函数提取标签并将它们分配给您的对象标签 属性。试试像
var pubs = client.Cypher
.Match("(s)")
.Where("s:APublisher OR s:BPublisher OR s:CPublisher OR s:DPublisher ")
.Return(s => new {
Pub = s.As<Publisher>()
PubLabels = s.Labels() })
.Results
.ToList();
var pubsList = new List<Publisher>(pubs.Count);
for each (var pub in pubs)
{
var publisher = pub.Pub;
publisher.Labels = pub.PubLabels;
pubsList.Add(publisher);
}
var pubs = client.Cypher
.Match("(s)")
.Where("s:APublisher OR s:BPublisher OR s:CPublisher OR s:DPublisher ")
.Return(s => s.As<Publisher>())
.Results.ToList<Publisher>();
通过上述查询,返回节点的所有属性并为每个节点创建 "Publisher" 个对象。
如何获取节点标签,并将其设置为新创建的 "Publisher" 对象的 "Labels" 属性?
谢谢..
您需要使用适当的函数提取标签并将它们分配给您的对象标签 属性。试试像
var pubs = client.Cypher
.Match("(s)")
.Where("s:APublisher OR s:BPublisher OR s:CPublisher OR s:DPublisher ")
.Return(s => new {
Pub = s.As<Publisher>()
PubLabels = s.Labels() })
.Results
.ToList();
var pubsList = new List<Publisher>(pubs.Count);
for each (var pub in pubs)
{
var publisher = pub.Pub;
publisher.Labels = pub.PubLabels;
pubsList.Add(publisher);
}