如何在Neo4jClient中检索路径? [英] How do I retrieve a path in Neo4jClient?

查看:42
本文介绍了如何在Neo4jClient中检索路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始将Neo4JClient用于.NET集成,并且(最终)我发现了大多数问题.但是,这个让我很烦.

I've recently started using Neo4JClient for my .NET integration and I have (eventually) figured most things out. However, this one's stumped me.

我对从Cypher查询(最好是在POCO对象中)获取路径感兴趣,因此我可以在这些查询的前端工作.

I'm interested in getting paths back from a Cypher query, preferably in a POCO object so I can work on a front end for these queries.

所以我的问题本质上是我如何在Neo4JClient中做到这一点?如果我不能,其他Neo4J .NET客户端是否支持此功能?

So my question essentially is how do I do this in Neo4JClient? And if I can't, do any of the other Neo4J .NET clients support this?

一个示例密码查询:

start n = node:idx(id="{id}")

MATCH p=(n)-[:RELATED_TO*0..3]-()

RETURN p;

因此,我希望特定节点周围所有具有传入和传出关系的节点的深度为3.还有另一种查询类型,但是它使用withs,我需要确定Neo4JClient是否/如何支持(另一个问题在那里).

So, I want all nodes around a specific node with both incoming and outgoing relationships to a depth of 3. There's another type of query too, but it uses withs and I need to find out if/how Neo4JClient supports that (another question there though).

到目前为止,我一直使用带有开放集和封闭集的Gremlin来向自定义对象填充有关其子关系的信息.它绝不是有效的,因此为什么我要以某种方式使用路径.有问题的自定义对象看起来像这样.

Up until now, I've been using Gremlin with open and closed sets to populate a custom object with information on it's sub-relationships. It's by no means efficient, hence why I'd like to do it with paths somehow. The customobject in question looks a little like this.

public class ConnectedNode : BaseNode
{
    public List<NodeRelation> RelatedNodes { get; set; }

    public ConnectedNode()
    {
        RelatedNodes = new List<NodeRelation>();
    }
}

public class NodeRelation
{
    // ... various properties for relationship payload type stuff
    public ConnectedNode RelatedNode { get; set; }
    public RelationshipDirection Direction { get; set; }
}

只要有效率,我都会为在我正在寻找的路径上拉回节点和关系数据的任何事情感到高兴.

I'm happy for anything that pulls back the node and relationship data on the path I'm looking for as long as it's efficient.

推荐答案

我最终解决了这个问题,并写了

I ended up working out the answer to this problem and have written a blog post on the subject. But so as you don't have to read the post for the jist of it...

首先,使用EXTRACT函数提取路径的节点和关系.这将为您提供2列的结果.自己选择一个包含两个节点和RelationshipInstances列表的POCO包含此两列的结果.然后使用投影"将查询检索到此类对象.瞧!

First, extract the nodes and relations of the path using the EXTRACT function. This will give you a 2-column result. Encompass this 2-columned result in a POCO of your own choosing that takes a list of nodes and RelationshipInstances. Then retrieve your query into this kind of object using a Projection. Voila!

希望这会有所帮助,对我有帮助.

Hope this helps, it helped me.

这篇关于如何在Neo4jClient中检索路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆