英文:
gremlin.net how to create vertex/edge with id
问题
我正在使用最新的Gremlin.net(3.6.1)和.NET 6。我正在尝试创建顶点/边,并为它们分配现有的ID,而不是让服务器为它们创建ID。
在Gremlin控制台中,可以使用以下方式实现:
g.addV('part').property(id, '59578').
但在C#中,显然无法完成此任务,因为属性键名为"id"。Neptune服务器始终为新创建的顶点/边创建UUID作为ID:
gtx.AddV("part").Property("id", "59578")
英文:
I am using latest gremlin.net (3.6.1) and NET 6. I am trying to create vertex/edge, and assign them with existing id, instead of letting server creating id for them.
In gremlin console, this could be done by
g.addV('part').property(id, '59578').
But in C#, this won't get the job done apparently, with property key name of "id". Neptune server always created UUID as id for newly created vertex/edge
gtx.AddV("part").Property("id", "59578")
答案1
得分: 2
在控制台中输入的内容和在.NET中提交的内容之间存在微妙的差异。对于.NET,你执行了以下操作:
Property("id", "59578")
而对于控制台,你执行了以下操作:
property(id, '59578')
正如你在前者中所选择的,将标识符视为String
值,并在后者中使用了T.id
。T.id
指的是顶点的标识符,而"id"
指的是属性键。在.NET中,你应该使用:
using static Gremlin.Net.Process.Traversal.T;
查看其他常见导入 此处。
英文:
There is a subtle difference between what you typed in the console and what you submitted in .NET. For .NET you did:
Property("id", "59578")
and for the console you did:
property(id, '59578')
As you can seen in the former you chose to make refer to the identifier as a String
value and in the latter you used T.id
. T.id
refers to the identifier of the vertex and "id"
refers to a property key. In .NET you should be making use of:
using static Gremlin.Net.Process.Traversal.T;
See other common imports here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论