I want to add/update vertex properties in through the following function to janusgraph with Gremlin.Net version=3.4.6; JanusGraph.Net version=0.2.2
public class DataManager
{
private readonly IGremlinClient client;
private readonly GraphTraversalSource g;
public DataManager()
{
this.client = JanusGraphClientBuilder
.BuildClientForServer(new GremlinServer("localhost", 8182))
.Create();
this.g = AnonymousTraversalSource.Traversal().WithRemote(
new DriverRemoteConnection(this.client));
}
public async Task EditVertexProperty(VertexDto vertexDto)
{
var traversal = this.g.V(vertexDto.Id);
if (!string.IsNullOrWhiteSpace(vertexDto.Label))
{
traversal = traversal.HasLabel(vertexDto.Label);
}
if (!traversal.HasNext())
{
throw new Exception("xxxxxxx");
}
foreach (var property in vertexDto.Properties)
{
if (property.IsList)
{
traversal = traversal.Property(Cardinality.List, property.PropertyKey, property.PropertyValue);
}
else
{
traversal = traversal.Property(Cardinality.Single, property.PropertyKey, property.PropertyValue);
}
}
await traversal.Promise(v => v.Iterate()).ConfigureAwait(false);
}
}
public class VertexDto
{
public string Id { get; set; }
public string Label { get; set; }
public List<Property> Properties { get; set; }
}
public class Property
{
public string PropertyKey { get; set; }
public string PropertyValue { get; set; }
public bool IsList { get; set; }
}
when i try to add or update a vertex property such as,
{
"id": 1234,
"properties":[
{
"propertyKey": "name",
"propertyValue": "sb"
}
]
}
but nothing has changed and it not throw exception. And i try in gremlin-server with g.V(1234).property("name", "sb").iterate() it worked. first i think traversal is stop when called HasNext(), but this doesn't seem to be the case.
What should i do. Thank for your help.