2017-07-03 114 views
0

我如何獲得與Neo4jClient庫節點的標籤neo4jclient得到節點標籤

這是我跑的代碼,並返回以下錯誤

您所提供的回報表達式使用方法除了由ICypherResultItem定義的 ,Neo4jClient.Cypher.All或 Neo4jClient.Cypher.Return。返回表達式需要 我們可以將其轉換爲Cypher,然後發送到服務器,執行 。您不能使用方法鏈,LINQ到對象或其他這樣的構造。如果要運行客戶端邏輯以在.NET中重構數據,請在查詢執行 之後使用Select呼叫,例如.Return(...).Results.Select(r => ...)。這種技術 在服務器端(在Neo4j中,通過Cypher)與客戶端(在.NET中)之間保持明確的分隔。

我的代碼

public List<string> getLabels(MyEvent targetEvent) 
{ 
    List<string> result = 
         this.client.Cypher.Match("(newE:MyEvent)") 
          .Where((MyEvent newE) => newE.myid == targetEvent.myid) 
          .Return(newE=> newE.Labels().ToString()) 
          .Results.ToList(); 
        return result; 
} 

回答

1

的文檔節「Get all labels for a specific user」顯示驗證碼:

graphClient.Cypher 
    .Match("(user:User)") 
    .Where((User user) => user.Id == 1234) 
    .Return(user => user.Labels()) 
    .Results 
立足於問題的錯誤消息

,我相信,你只需要刪除toString()從退貨,如下:

public List<string> getLabels(MyEvent targetEvent) 
{ 
    List<string> result = this.client.Cypher.Match("(newE:MyEvent)") 
     .Where((MyEvent newE) => newE.myid == targetEvent.myid) 
     .Return(newE=> newE.Labels()) 
     .Results.ToList(); 
     return result; 
}