简体   繁体   English

Neo4jClient C#如何获取所有节点

[英]Neo4jClient C# How to get all nodes

I am using Neo4jClient and Neo4j graph database in C# and I am wondering how I can retrieve all nodes with Neo4jClient. 我在C#中使用Neo4jClient和Neo4j图形数据库,我想知道如何使用Neo4jClient检索所有节点。

Here is the cypher query to retrieve all nodes which have a relationship to "KNOWS" independently of the relationship direction : 这是密码查询,用于检索与“ KNOWS”有关系的所有节点,而与关系方向无关:

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

And here is the C# code with Neo4jClient : 这是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");

However Neo4jClient doesn't allow to retrieve all nodes from * but only from a start point, here the root node. 但是Neo4jClient不允许从*检索所有节点,而只能从起点(此处是根节点)检索。
How can I say with Neo4jClient to retrieve all nodes and not only nodes attached to root node? 我如何用Neo4jClient检索所有节点,而不仅检索附加到根节点的节点?

It seems there is no way to query nodes from * through Neo4jClient.GraphClient. 似乎没有办法通过Neo4jClient.GraphClient从*查询节点。

However I can do that by executing a query with RawGraphClient : 但是我可以通过使用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();

Using Node<T>.StartCypher(identity) is a shortcut to both create a query and start it all in one go. 使用Node<T>.StartCypher(identity)是创建查询并一次性启动所有查询的快捷方式。

Instead, just create your query straight from the client: 而是直接从客户端创建查询:

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

Then, you have full control over the START clause. 然后,您可以完全控制START子句。

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. 我当然认为这个问题是因为尚未在NEO4JClient库中实现它,此外,现在的问题是Neo4JClient团队遮盖了ExecuteGetCypherResults,所以现在我们将不得不直接实现IRawGraphClient或仅使用HttpWebRequest来实现。 :-/ At least that is what I concluded after seeing some info in their repository in bitbucker. :-/至少这是我在bitbucker的存储库中看到一些信息后得出的结论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM