0

我无法弄清楚如何使用 neo4j 客户端中的 cypher linq Return 函数在 return 子句中放置过滤器。

我正在尝试进行这样的查询:

START Parents = node:app_fulltext('name:"City"'),
 MATCH Parents-[?:ChildOf]-Apps 
 WITH collect(Apps.Title) as myapps, collect(Parents.Name) as myparents
 RETURN myapps, filter(x in parents : not x in myapps) as myfilteredparents

我试过从这样的 with 子句开始

.With("collect(Apps.Title) as myapps, collect(Parents.Name) as myparents")
.Return("myapps, filter(x in parents : not x in myapps) as myfilteredparents")

但我无法将字符串传递给 Return 方法,如果我尝试将某种过滤器传递给 LINQ lambda,则会出现The return expression that you have provided uses methods other than those defined by ICypherResultItem.错误。

4

1 回答 1

1

现在,具有多个身份的复杂返回表达式在 Neo4jClient 中有点棘手。我对如何很好地支持他们持开放态度。语法是困难的部分。

这是在正确的轨道上:

.With("myapps, filter(x in parents : not x in myapps) as myfilteredparents")
.Return("myapps, filter(x in parents : not x in myapps) as myfilteredparents")

但是,您要应用过滤器两次:一次在 中WITH,然后在RETURN.

使用该WITH子句将其展平为简单的身份(myappsmyfilteredparents),然后RETURN是那些。

这段代码未经测试,直接输入到答案窗口中,但是你想要的那种:

.With("myapps, filter(x in parents : not x in myapps) as myfilteredparents")
.Return((myapps, myfilteredparents) => new
{
    Apps = myapps.As<IEnumerable<string>>(),
    Parents = myfilteredparents.As<IEnumerable<Node<City>>>()
})

With调用将数据塑造成一个简单的结果集。该Return调用描述了将其反序列化为的结构。

于 2013-04-02T13:19:16.533 回答