neo4jClient使用参数创建具有动态标签的节点 [英] neo4jClient create node with dynamic label using paramters
问题描述
我正在构建一个应用程序,使用户能够构建自己的图形.我一直在使用参数进行所有查询和创建.但是,当我想让用户能够创建一个节点时,他们还可以在该节点上随意标记它(尊重空字符串标签上的neo4j限制).我将如何参数化此类交易?
I am building an app that give users the ability to construct there own graphs. I have been using parameters for all queries and creates. But when I want to give users the ability to create a node where they can also Label it anything they want(respecting neo4j restrictions on empty string labels). How would I parameterize this type of transaction?
我尝试过:
.CREATE("(a:{dynamicLabel})").WithParams(new {dynamicLabel = dlabel})...
但是这会导致neo的语法错误.我很想串联,但是担心这可能会给我的应用程序带来注入风险.
But this yields a syntax error with neo. I am tempted to concatenate, but am worried that this may expose an injection risk to my application.
我很想建立自己的类,该类读取预期的字符串并拒绝任何类型的neo语法,但这会限制我的用户,而我宁愿不这样做.
I am tempted to build up my-own class that reads the intended string and rejects any type of neo syntax, but this would limit my users a bit and I would rather not.
推荐答案
有一个开放的neo4j 问题4334 ,这是一项功能请求,用于添加在CREATE
期间参数化标签的功能.因此,这还不可能.
There is an open neo4j issue 4334, which is a feature request for adding the ability to parameterize labels during CREATE
.So, this is not yet possible.
该问题包含一条注释,该注释建议生成带有硬编码标签的CREATE
语句,这将起作用.不幸的是,它的性能不如使用参数(在这种情况下应支持).
That issue contains a comment that suggests generating CREATE
statements with hardcoded labels, which will work. It is, unfortunately, not as performant as using parameters (should it ever be supported in this case).
这篇关于neo4jClient使用参数创建具有动态标签的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!