gpt4 book ai didi

c# - 当您不知道分区键时使用 DocumentClient.ReadDocumentAsync

转载 作者:行者123 更新时间:2023-12-02 08:27:50 25 4
gpt4 key购买 nike

我遇到一种情况,我需要检索特定文档,但我不知道它是 PartitionKey。

该方法如下所示:

    public async Task<T> GetItemAsyncNoGroupId(string id)
{
try
{
Document document = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(DatabaseId, CollectionId, id),
new RequestOptions() { PartitionKey = new PartitionKey(Undefined.Value) });

return (T)(dynamic)document;
}
catch (DocumentClientException e)
{
if (e.StatusCode == System.Net.HttpStatusCode.NotFound)
{
return null;
}
else
{
throw;
}
}
}

我将 Undefined.Value 传递给 PartitionKey 对象,但这不起作用。我也没有将任何 PartionKey 对象传递到 ReadDocumentAsync 方法中,但这不起作用。我总是收到“无内容”回传。关于如何让它发挥作用有什么建议吗?

最佳答案

您需要使用跨分区查询。了解它 here .

关于c# - 当您不知道分区键时使用 DocumentClient.ReadDocumentAsync,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63506811/

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