2013-04-02 45 views
0

我無法弄清楚如何在neo4j客戶端中使用密碼linq返回函數在return子句中放置過濾器。如何在.net中執行密碼查詢的return子句中的過濾器Neo4jClient

我試圖做這樣的查詢:

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("collect(Apps.Title) as myapps, collect(Parents.Name) as myparents") 
.Return("myapps, filter(x in parents : not x in myapps) as myfilteredparents") 

,但我不能在一個字符串傳遞給返回方法,如果我嘗試將某種過濾器傳入LINQ lambda中,則會出現The return expression that you have provided uses methods other than those defined by ICypherResultItem.錯誤。

回答

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") 

但是你應用濾鏡兩次:在RETURN曾在WITH,然後再次。

使用WITH子句將其簡化爲簡單標識(myapps,myfilteredparents),然後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描述了將其反序列化爲的結構。

+0

對不起,在我的問題中複製並粘貼錯誤,我在代碼中有權使用子句,但As 部分指出我朝着正確的方向 – MonkeyBonkey

相關問題