我遇到一种情况,我需要检索特定文档,但是我不知道它是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方法中,这是行不通的。我总是回传“无内容”。关于如何使它起作用的任何建议?