2014-01-23 103 views
0

我有這個疑問轉換查詢neo4jclient代碼

MATCH (root:Lvl1)-[:HAVE_OTDEL|HAVE_GROUP*0..]->(leaf) RETURN DISTINCT leaf; 

CypherQuery query = 
       new CypherQuery(
        string.Format("MATCH (root:Lvl1)-[:HAVE_OTDEL|HAVE_GROUP*0..]->(leaf) RETURN DISTINCT leaf;"), new Dictionary<string, object>(), CypherResultMode.Set); 
      var persons = ((IRawGraphClient) client).ExecuteGetCypherResults<treeview>(query).ToList(); 

treeview.cs

class treeview 
    { 
     private string Name { get; set; } 
     private string lvl { get; set; } 
    } 

這回我錯誤的序列化...

+0

我們只是想猜測錯誤是什麼? –

回答

3

請不要使用ExecuteGetCypherResults。文件告訴你不要使用它。我已經告訴過你不要使用它(Convert cypher query to c#)。你不需要使用它。請不要使用它。我不知道你在哪裏找到它,但該文件顯然是錯誤的。

現在,您的查詢到C#的正確翻譯是:

client.Cypher 
    .Match("(root:Lvl1)-[:HAVE_OTDEL|HAVE_GROUP*0..]->(leaf)") 
    .ReturnDistinct(leaf => leaf.As<treeview>()) 
    .Results 

如果不爲你工作,那麼你需要給我們更多的信息。你說「回到我的錯誤」,但你從來沒有列出這個錯誤。你爲什麼不發佈它?這可能是我們幫助你的一條信息。

+0

其返回8項它包含空http://i019.radikal.ru/1401/4c/e910d80285c6.png –

+0

其返回我真正的物品計數,但在treeview我查看空數據 –

+0

'空'響應是因爲返回的對象不能反序列化回你的'treeview'對象。嘗試將屬性的「private」修飾符(即'private string Name {get; set;}')更改爲public:'public string Name {get; set;}'。 –