gremlin.net how to create vertex/edge with id

199 Views Asked by At

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

There are 1 best solutions below

0
On BEST ANSWER

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.