gremlin.net如何创建带有ID的顶点/边

huangapple go评论77阅读模式
英文:

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 gremlin.net如何创建带有ID的顶点/边
gtx.AddV("part").Property("id", "59578")

答案1

得分: 2

在控制台中输入的内容和在.NET中提交的内容之间存在微妙的差异。对于.NET,你执行了以下操作:

Property("id", "59578")

而对于控制台,你执行了以下操作:

property(id, '59578')

正如你在前者中所选择的,将标识符视为String值,并在后者中使用了T.idT.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.

huangapple
  • 本文由 发表于 2023年1月9日 12:12:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/75053117.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定