gpt4 book ai didi

neo4j - 使用 Neo4jClient 更新关系/有效负载

转载 作者:行者123 更新时间:2023-12-04 04:59:05 24 4
gpt4 key购买 nike

我是 Neo4j 和 Neo4jClient 的新手。我正在尝试更新现有关系。这是我创建关系的方式。

var item2RefAddedBefore = _graphClient.CreateRelationship((NodeReference<Item>)item2Ref,
new AddedBefore(item1Ref, new Payload() { Frequency = 1 }));

对于这个特定的用例,我想在节点和关系已经存在时更新有效负载。我主要将 Cypher 与 Neo4jClient 一起使用。

感谢任何帮助!

最佳答案

用这个 IGraphClient签名:

void Update<TRelationshipData>(RelationshipReference<TRelationshipData> relationshipReference, Action<TRelationshipData> updateCallback)
where TRelationshipData : class, new();

像这样:
graphClient.Update(
(RelationshipReference<Payload>)item2RefAddedBefore,
p => { p.Foo = "Bar"; });

更新:现在的语法有点尴尬,其中 CreateRelationship只返回 RelationshipReference而不是 RelationshipReference<TData>但是 Update需要后者,因此您需要显式转换它。老实说,我们可能不会很快解决这个问题,因为 Neo4j 和 Neo4jClient 的所有投资都用于通过 Cypher 进行突变。

关于neo4j - 使用 Neo4jClient 更新关系/有效负载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16362779/

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