NET Core如何编写Neo4j密码的用户定义函数和存储过程查询? [英] How to write user defined functions and stored procedure query of cipher of neo4j in .net core?

查看:87
本文介绍了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数据库中添加数据?

How can I write that query in .net core API to add data in neo4j database?

推荐答案

流利的api包含您在此处需要的所有内容,因此:

The fluent api contains everything you need here, so:

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 以仅使用 = 来设置所有属性:

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:

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();

这将取决于 val 到底有什么,请通读

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).

这篇关于NET Core如何编写Neo4j密码的用户定义函数和存储过程查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆