本文介绍了Neo4jClient/Cypher查询返回对象,但未设置属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是无法通过Neo4jClient和Cypher从Neo4j中获取对象.
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;
我在myList [0]中得到一个User对象,但是它的属性为空.
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)
(Neo4j 1.8 MS5, Neo4jClient 1.0.0.388)
/Neo4jClient/Neo4j noob.
/Neo4jClient/Neo4j noob.
推荐答案
是的!我像这样更改为Node:
Yay! I changed to Node like so:
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.
where 1 is the ID of the User node.
这篇关于Neo4jClient/Cypher查询返回对象,但未设置属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!