如何使用 Neo4jClient 从 Neo4j 获取节点和边到 C# 对象结构

问题描述 投票:0回答:0

我正在使用 Neo4jClient,并尝试从父节点开始并获取所有相关节点来构建并返回对象。

对象很简单:

public class NodeModel 
{
  public string Key {get; set;}
  public IEnumerable<EdgeModel> Edges {get; set;}
}

public class EdgeModel 
{
  public string Key {get; set;}
  public string EdgeType {get; set;}
  public IEnumerable<NodeModel> ChildNodes {get; set;}
}

我尝试返回的节点和边的示例是: Related nodes example

如何使用 neo4jclient 编写查询,该查询将返回节点和边作为我的 NodeModel 对象或我可以以编程方式使用的类似对象。当尝试类似的事情时:

_graphClient.Cypher
  .Match("(parentNode:TestLabel WHERE parentNode.Key = $key)")
  .OptionalMatch("(parentNode)->[r:RELATED_TO*]->(childNode:TestLabel)")

我不确定要返回什么以及如何以适合我的模型的方式处理结果。另外,如果可能的话,我宁愿不使用 APOC 插件。

感谢您的帮助!

c# neo4j cypher neo4jclient
© www.soinside.com 2019 - 2024. All rights reserved.