简体   繁体   English

Neo4JClient:如何找到给定节点的关系列表(任何类型)?

[英]Neo4JClient: How can I find a list of relationships (of any type) for a given node?

I know how to get the related nodes, and to specify the relationships to find those nodes, but there doesn't seem to be any mechanism to find the relationships themselves? 我知道如何获取相关节点,以及如何指定关系以查找那些节点,但是似乎没有任何机制可以自行找到关系?

Looking through the source code for Neo4JClient you can find the type "Relationship" but it's only used when creating Relationships, not in retrieving them. 查看Neo4JClient的源代码,您可以找到“ Relationship”类型,但是它仅在创建Relationships时使用,而不是在检索它们时使用。

When retrieving, you can get a "RelationshipInstance", but it consists of a RelationshipReference and two NodeReferences.. None of which have any data associated with them besides the unique integer ID associated with each. 检索时,您可以获取“ RelationshipInstance”,但是它由一个RelationshipReference和两个NodeReferences组成。除了与它们关联的唯一整数ID之外,没有任何与它们关联的数据。

It sounds like you want access to data stored on relationships. 听起来您想访问存储在关系中的数据。 We refer to these as "payloads". 我们将这些称为“有效载荷”。

You can query them like so: 您可以像这样查询它们:

client
    .RootNode
    .OutE<FooPayload>()
    .Select(p =>
    {
        p.Reference.Id,         // Relationship ID
        p.StartNodeReference,   // Outbound vertex
        p.EndNodeReference,     // Inbound vertex
        p.Data,                 // Payload as FooPayload
        p.Data.Bar              // A property in the payload
    });

More likely, you'd want to use an overload of OutE that filters the relationships by type, like: 您更可能希望使用OutE的重载,该重载按类型过滤关系,例如:

client
    .RootNode
    .OutE<FooPayload>("HAS_FOO")

If you use the overload of OutE without the generic type parameter, you will get the references but no payload data (because we don't know what to deserialize the data into). 如果在不使用泛型类型参数的情况下使用OutE的重载,则将获得引用,但没有有效载荷数据(因为我们不知道将数据反序列化为什么)。

HTH. HTH。

-- Tatham -塔瑟姆

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

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