繁体   English   中英

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

[英]How to write user defined functions and stored procedure query of cipher of neo4j in .net core?

我有一个这样的查询

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 核心 API 中编写该查询以在 neo4j 数据库中添加数据?

流利的 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文档(可能是Replacing PropertiesMutating properties )。

暂无
暂无

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

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