【发布时间】:2020-07-03 15:24:50
【问题描述】:
当我们尝试运行查询以检查文档是否存在带有分区键的情况时,我们会遇到异常。
代码:
var exists = GetQuery(new QueryOptions() { PartitionKey = customer.Id })
.Where(x => x.Customer.Id == customer.Id && x.Period == period).Select(x => x.Id).Take(1)
.AsEnumerable().FirstOrDefault() != null;
if (exists)
{
//No insert is made.
return null;
}
InnerException = {"Message: {"Errors":["发生未知错误 在处理这个请求时。如果问题仍然存在,请联系 Azure 支持:http://aka.ms/azure-support"]}\r\nActivityId: 60dae5e2-c542-462f-bcca-640216dac4d7,请求 URI: /apps/DocDbApp/services/DocDbServer11/partitions/a4cb4957-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, RequestStats: \r\nRequestStartTime: 2020-07-03T15:20:24.3705569Z, RequestEndTime:2020-07-03T15:20:24.3725571Z,区域数 尝试:1\r\n响应时间:2020-07-03T15:20:24.3725571Z, 存储结果:存储物理地址: rntbd://127.0.0.1:10253/apps/DocDbApp/services/DocDbServer11/partitions/a4cb4957-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, LSN:258197,GlobalCommittedLsn:-1,PartitionKeyRangeId:0,IsValid: 真,StatusCode:500,SubStatusCode:0,RequestCharge:1,ItemLSN: -1, SessionToken: -1#258197, UsingLocalLSN: True, TransportException: null, ResourceType: Document, OperationType: Query\r\n, SDK: Microsoft.Azure.Documents.Common/2.9.2、Windows/10.0.18363 documentdb-netcore-sdk/2.10.0"}
我怎样才能成功运行这段代码?我们正在使用 sdk2。
【问题讨论】:
-
请提供更多细节。其余代码看起来如何?
-
剩下的代码只是来自 documentclient 的 IQueryable,请求选项带有分区键,没有别的。
标签: c# .net azure azure-cosmosdb