2012-07-06 64 views
1

我只是不能通過Neo4jClient和Cypher獲得Neo4j的對象。Neo4jClient/Cypher查詢返回的對象,但沒有設置屬性

var client = new GraphClient(new Uri("http://mymachine:7474/db/data")); 
client.Connect(); 
var myList = client.RootNode.StartCypher("root") 
    .Match("root-[:RELATED_TO]->(user)") 
    .Return<User>("user").Results; 

我在myList [0]中得到一個User對象,但它的屬性是空的。

我打通

client.ExecuteGetCypherResults<User>(
    new CypherQuery("start n=node(1) return n;",null, CypherResultMode.Set) 
); 

有我忽視什麼明顯的一點是相同的(空Properties對象)?

(Neo4j的1.8 MS5,Neo4jClient 1.0.0.388)

/Neo4jClient/Neo4j的小白。

回答

1

耶!我改變到節點像這樣:

var myList = client.RootNode.StartCypher("root") 
    .Match("root-[:RELATED_TO]->(user)") 
    .Return<Node<User>>("user").Results; 

最後

var myList = client.RootNode.StartCypher("root") 
    .Match("root-[:RELATED_TO]->(user)") 
    .Return<Node<User>>("user").Results 
    .Select(nu => nu.Data); 

最簡單的例子應該是:

var myList = client.ExecuteGetCypherResults<Node<User>>(
    new CypherQuery("start n=node(1) return n;", null, CypherResultMode.Set)) 
.Select(un => un.Data); 

其中1是用戶節點的ID。

+0

不錯,很高興看到你解決了它。 – 2012-07-09 12:28:32

+0

一年後使用Google搜索相同的問題,我發現了另一個罪魁禍首。 User類的字段必須是公共的。內部是不夠的。 – LosManos 2013-09-17 19:01:12

+1

而不是使用退貨>,然後用Select呼叫將其扔掉,只需使用Return 即可。 – 2013-12-17 10:18:08

相關問題