Gremlin.NET:使用.Next()执行查询会引发NullReferenceException

Chr*_*ris 5 c# gremlin azure-cosmosdb

从Azure Cosmos DB Graph API示例开始:https: //github.com/Azure-Samples/azure-cosmos-db-graph-gremlindotnet-getting-started

我有兴趣使用Gremlin.NET(该示例使用版本3.2.7)使用C#类执行查询,而不是编写字符串查询并使用该gremlinClient.SubmitAsync<dynamic>("...")方法执行它们.

但是当我执行以下代码时,我得到了一个

Gremlin.Net.Driver.Connection.d__14`1.MoveNext()中的NullReferenceException

在打电话时 .Next()

var gremlinServer = new GremlinServer(hostname, port, enableSsl: true,
    username: "/dbs/" + database + "/colls/" + collection,
    password: authKey);

var graph = new Graph();
var g = graph.Traversal().WithRemote(new DriverRemoteConnection(new GremlinClient(gremlinServer)));

var vertex = g.V().HasLabel("person").Next();
Console.WriteLine(vertex);
Run Code Online (Sandbox Code Playgroud)

不幸的是,我还没有找到任何关于如何使用Gremlin.NET的文档,如果你们中的某些人可以指点我一些"入门",那就太好了.

编辑: Azure Cosmos DB Data Explorer的查询结果如下所示:

[
  {
    "id": "thomas",
    "label": "person",
    "type": "vertex",
    "properties": {
      "firstName": [
        {
          "id": "9015b584-375f-4005-af00-f49d6e2d6b94",
          "value": "Thomas"
        }
      ],
      "age": [
        {
          "id": "c2300d19-12a0-474a-9405-eb89466bcbb3",
          "value": 44
        }
      ]
    },
    "_isRoot": true,
    "_isFixedPosition": true
  }
]
Run Code Online (Sandbox Code Playgroud)

Flo*_*ann 5

这不适用于Cosmos DB的原因很简单,Cosmos DB不支持Gremlin Bytecode,这就是当您使用遍历API时发送到服务器的内容.因此,您目前唯一的选择是将查询真正写为字符串,然后将这些查询字符串发送到服务器.

关于文档:Gremlin遍历可以用不同的语言编写(有关Gremlin的更多信息,请参阅Gremlin Graph Traversal Machine and Language).因此,TinkerPop文档也适用于Gremlin.Net,文档中的Gremlin.Net部分仅解释了Gremlin.Net特有的方面.