简体   繁体   English

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

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

I have a query like that我有一个这样的查询

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

How can I write that query in .net core API to add data in neo4j database?如何在 .net 核心 API 中编写该查询以在 neo4j 数据库中添加数据?

The fluent api contains everything you need here, so:流利的 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();

What I might look at if I were you is whether you can just shorten the SET to just use = to set all the properties:如果我是你,我可能会看看你是否可以缩短SET以仅使用=来设置所有属性:

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

Or maybe a += if you need it to be additive:或者如果你需要它是加法的,也许是一个+=

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

It's going to depend on what exactly val has though, have a read through of the SET documentation (maybe Replacing Properties or Mutating properties ).这将取决于val到底有什么,通读SET文档(可能是Replacing PropertiesMutating properties )。

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

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