neo4j - 如何在.net core中编写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 核心 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 Properties或Mutating properties)。
推荐阅读
- scala - 如何在子查询scala spark中使用聚合函数
- python - 使用 Gunicorn 和 gevent 从 Heroku 上的 Flask 应用程序运行多个线程
- sql - SQL从多个字符串列创建row_number
- sql - 适用于 SQL Server CURSOR STATIC 的 Oracle 12 C 等效项
- javascript - PHP 扫描一个目录,并且对于找到的每个文件,在它自己的 DIV 元素中回显该文件的内容
- spring-cloud - 服务已在 Eureka 注册,但由于 DNS_PROBE_FINISHED_NXDOMAIN 而无法从浏览器访问
- digital-signature - 如果任何人都可以删除PE的数字签名并辞职,如何知道PE是原始的
- java - 如何准确测量 API POST 请求的响应时间
- mysql - 无法加载身份验证插件'caching_sha2_password' - MySql 和 Ruby on Rails
- tomcat - Tomcat 静态缓存“cacheTtl”