gpt4 book ai didi

azure-cosmosdb - CosmosDB C# Gremlin - 发送查询时出现异常

转载 作者:行者123 更新时间:2023-12-03 22:43:05 26 4
gpt4 key购买 nike

取自:https://learn.microsoft.com/en-us/azure/cosmos-db/create-graph-dotnet

我在 .wait() 部分遇到异常:

   NullReferenceException: Object reference not set to an instance of an object.

at Gremlin.Net.Driver.Connection.ReceiveAsync[T]()
at Gremlin.Net.Driver.Connection.SubmitAsync[T](RequestMessage requestMessage)
at Gremlin.Net.Driver.ProxyConnection.SubmitAsync[T](RequestMessage requestMessage)
at Gremlin.Net.Driver.GremlinClient.SubmitAsync[T](RequestMessage requestMessage)
at Gremlin.Net.Driver.GremlinClientExtensions.SubmitAsync[T](IGremlinClient gremlinClient, String requestScript, Dictionary`2 bindings)

代码:

    private static string database = "db";
private static string collection = "col";
private static string hostname = "grem-test.gremlin.cosmosdb.azure.com";
public void test()
{
var gremlinServer = new GremlinServer(hostname, 443, enableSsl: true,
username: "/dbs/" + database + "/colls/" + collection,
password: authKey);
var gremlinClient = new GremlinClient(gremlinServer);
var grem = "g.V()";
var t = gremlinClient.SubmitAsync<dynamic>(grem);
t.Wait();

foreach (var result in t.Result)
{
// The vertex results are formed as dictionaries with a nested dictionary for their properties
string output = JsonConvert.SerializeObject(result);
Console.WriteLine(String.Format("\tResult:\n\t{0}", output));
}

最佳答案

应该是:

    var task = gremlinClient.SubmitAsync<dynamic>(grem);
task.Wait();

取自 Gremlin C# 示例:

                 // Create async task to execute the Gremlin query.
var task = gremlinClient.SubmitAsync<dynamic>(query.Value);
task.Wait();

关于azure-cosmosdb - CosmosDB C# Gremlin - 发送查询时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52748380/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com