Neo4jClient/Cypher query returns object but without setting properties

痴心易碎 提交于 2020-01-05 19:14:19

问题


I just can't get an object out of Neo4j through Neo4jClient and 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;

I get a User object in myList[0] alright but its properties are empty.

I get the same (object with empty properties) through

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

What obvious thing have I overlooked?

(Neo4j 1.8 MS5, Neo4jClient 1.0.0.388)

/Neo4jClient/Neo4j noob.


回答1:


Yay! I changed to Node like so:

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

and finally

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

The simplest example should be:

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

where 1 is the ID of the User node.



来源:https://stackoverflow.com/questions/11366406/neo4jclient-cypher-query-returns-object-but-without-setting-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!