如何在.net内核中编写neo4j密码的用户定义函数和存储过程查询



我有一个类似的查询

call apoc.load.json("url") yield value
unwind value.learningPaths as val
merge (n:learningPaths {id:val.uid}) Set n.modified = val.last_modofied,
n.type     = val.type,
n.locale   = val.locale,
n.childrens= val.number_of_children,
n.summary  = val.summary,
n.minutes  = val.duration_in_minutes,
n.title    = val.title,
n.levels = val.levels,
n.roles = val.roles,
n.modules = val.modules,
n.products = val.products

如何在.net core API中编写该查询以将数据添加到neo4j数据库中?

fluent api包含您在这里需要的一切,因此:

await client.Cypher.Call("apoc.load.json('url')").Yield("value")
.Unwind("value.learningPaths", "val")
.Merge("(n:learningPaths {id:val.uid})")
.Set(@"n.modified = val.last_modofied,
n.type     = val.type,
n.locale   = val.locale,
n.childrens= val.number_of_children,
n.summary  = val.summary,
n.minutes  = val.duration_in_minutes,
n.title    = val.title,
n.levels = val.levels,
n.roles = val.roles,
n.modules = val.modules,
n.products = val.products")
.ExecuteWithoutResultsAsync();

如果我是你,我可能会考虑是否可以将SET缩短为仅使用=来设置所有属性:

await client.Cypher.Call("apoc.load.json('url')").Yield("value")
.Merge("(n:learningPaths {id:val.uid})")
.Set(@"n = val")
.ExecuteWithoutResultsAsync();

或者如果你需要+=作为添加剂:

await client.Cypher.Call("apoc.load.json('url')").Yield("value")
.Merge("(n:learningPaths {id:val.uid})")
.Set(@"n += val")
.ExecuteWithoutResultsAsync();

这将取决于val到底有什么,不过,要通读SET文档(可能是替换属性或突变属性(。

相关内容

  • 没有找到相关文章

最新更新