gpt4 book ai didi

c# - Neo4jClient 测试节点是否存在、获取 NodeReference 或创建的最佳方法

转载 作者:太空宇宙 更新时间:2023-11-03 13:34:09 25 4
gpt4 key购买 nike

这是我的问题。我在我的 Neo4j 人员列表中插入(具有唯一标识符)并在他们之间创建关系。

知道这个人是否已经存在于 Neo4j 中然后创建/更新它的最有效方法是什么?由于 Neo4jclient 不支持标签,将类型信息存储为节点的属性是否更有效,还是将所有相同类型的节点链接到该类型的“根节点”更好?

提前谢谢你,

埃默里克

最佳答案

Neo4jClient 通过标准 Cypher 支持标签。 (构建 1.0.0.602 及更高版本。)

graphClient
.Merge("(p:Person {jim}")
.WithParam("jim", new Person { Name = "Jim" })
.ExecuteWithoutResults();

你也可以返回:

var jimNode = graphClient
.Merge("(p:Person {jim}")
.WithParam("jim", new Person { Name = "Jim" })
.Return(p => p.Node<Person>())
.Results
.Single();

关于c# - Neo4jClient 测试节点是否存在、获取 NodeReference 或创建的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19266023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com