Azure Cosmos DB:通过GUID检索文档

时间:2020-03-30 07:53:37

标签: c# azure azure-cosmosdb

我已将带有GUID的文档存储在Cosmos DB容器中。但是,当我尝试使用Where()子句检索同一文档时,它无法返回该文档。

这是我用来查询文档的C#代码:

var application = await client
  .CreateDocumentQuery<Document>(collectionLink, feedOptions)
  .Where(d => d.Id == "b0e6b18a-54rgf-497d-45g7-bcb17afbdtyh")
  .Where(d => d.Type == "application")
  .Where(d => d.DeletedDateTime == null)
  .AsDocumentQuery()
  .ExecuteNextAsync<Document>(cancellationToken)
  .ConfigureAwait(false);

这是Azure Cosmos DB中的示例Json文件:

{
    "id": "b0e6b18a-54rgf-497d-45g7-bcb17afbdtyh",
    "Type": "application",
    "ApplicationId": "b0e6b18a-54rgf-497d-45g7-bcb17afbdtyh",
    "Name": "test",
    "Description": "test application.",
    "Company": "test",
    "OwnerEmailId": "xyz@xyz.com",
    "CreatedDateTime": "",
    "ModifiedDateTime": "",
    "DeletedDateTime": null,   
    "Resources": [],
    "_rid": "removedId",
    "_self": "removedId",
    "_etag": "removedID",
    "_attachments": "attachments/",
    "_ts": 1567604515
}

在最终输出中,没有匹配的记录。缺少什么?

重要!。此代码在我的开发环境中有效。但是在测试环境中失败。

0 个答案:

没有答案