2

我在 C# 中使用 Neo4jClient 和 Neo4j 图形数据库,我想知道如何使用 Neo4jClient 检索所有节点。

这是检索与“KNOWS”有关系的所有节点的密码查询,与关系方向无关:

start n =node(*) match n-[r:KNOWS]-(friend) return friend;

这是带有 Neo4jClient 的 C# 代码:

var client = new GraphClient(new Uri("http://localhost:7474/db/data"));
client.Connect();

var cypherFluentQueryReturned = client.RootNode
                .StartCypher("n")
                .Match("n-[:KNOWS]->friend")
                .Return<Node<Person>>("friend");

但是 Neo4jClient 不允许从 * 中检索所有节点,而只能从起点检索,这里是根节点。
我怎么能用 Neo4jClient 来检索所有节点,而不仅仅是连接到根节点的节点?

似乎没有办法通过 Neo4jClient.GraphClient 从 * 查询节点。

但是我可以通过使用 RawGraphClient 执行查询来做到这一点:

CypherQuery query = new CypherQuery("start n=node(*) match n-[KNOWS]-(person) return person", new Dictionary<string, object>(), CypherResultMode.Set);
var persons = ((IRawGraphClient)client).ExecuteGetCypherResults<Person>(query).ToList();
4

2 回答 2

1

使用Node<T>.StartCypher(identity)是创建查询并一次性启动它的快捷方式。

相反,只需直接从客户端创建查询:

client
    .Cypher
    .Start(new { n = All.Nodes })
    .Return<object>("n")

然后,您可以完全控制该START子句。

于 2013-03-22T04:41:15.510 回答
-1

I certainly think that the issue is because it has not yet been implemented in the NEO4JClient library, furthermore, the problem now is that the Neo4JClient team obscured ExecuteGetCypherResults, so now we will have to either implement IRawGraphClient directly or just plain using HttpWebRequest. :-/ At least that is what I concluded after seeing some info in their repository in bitbucker.

于 2012-11-06T21:34:57.143 回答