neo4jclient的return方法中的方法链接

问题描述 投票:1回答:1

我无法弄清楚以下密码查询对应的neo4jclient是什么:

match (n)
return n.Property, n.AnotherProperty, n.head(label(n))

这是我到目前为止所拥有的:

.Match("n")
.Return((n) => new SomeNode
{
    Property = n.As<SomeNode>.Property,
    AnotherProperty = n.As<SomeNode>.AnotherProperty,
    Label = n.Labels() //This gives all labels, I only need the head. I can't chain it with ".head()"
}

我已经在stackoverflow和wiki上四处查看,但是找不到有关链接函数的任何信息。

是否有按照我在此描述的方式实现链接的方法,我是否需要构造另一个查询以单独获取标签,然后将该列表的开头并将其添加到SomeNode,还是我错过了一个更好的方法? ,完全不同的方法?

我最初遇到错误时说到这里:“如果要运行客户端逻辑以在.NET中重塑数据,请在执行查询后使用Select调用,例如.Return(…).Results.Select(r =>…)。”但是,Wiki上也没有这样的示例。

c# neo4j neo4jclient
1个回答
0
投票

我很快想到的最好的方法是将Return.As用于您想在Return中进行的任何操作,例如:

.Match("(n)")
.Return((n) => new SomeNode
{
    Property = n.As<SomeNode>.Property,
    AnotherProperty = n.As<SomeNode>.AnotherProperty,
    Label = Return.As<string>("head(labels(n))")
}

可以使用With

.Match("(n)")
.With("n, head(labels(n)) AS firstLabel")
.Return((n, firstLabel) => new SomeNode
{
    Property = n.As<SomeNode>.Property,
    AnotherProperty = n.As<SomeNode>.AnotherProperty,
    Label = firstLabel.As<string>()
}

两者之间的很大一部分-您必须以两种方式将head位写为string:/

© www.soinside.com 2019 - 2024. All rights reserved.