c# - Azure Cosmos DB:按 GUID 检索文档
问题描述
我在 Cosmos DB 容器中存储了一个带有 GUID 的文档。但是,当我尝试使用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
}
在最终输出中,没有匹配的记录。什么不见了?
重要的!此代码在我的开发环境中运行。但它在测试环境中失败。
解决方案
推荐阅读
- flutter - 'package:flutter/src/gestures/tap.dart':断言失败:第 201 行 pos 14:'_down == null && _up == null':不正确
- reactjs - 从对象列表中删除对象
- php - 外键限制 Laravel 8 上的迁移,语法错误
- laravel - 在 Vue 组件 Laravel VueJS 项目中显示 PDF 文件
- java - 如何在 Spring Boot 中使用 Thymeleaf 保存角色类型?
- java - Micronaut:micronaut 启动后如何运行一个类的方法?
- javascript - 如何直接从 React(前端)点击 AWS Elastic Search 查询
- python - 连接错误和另一个错误
- python - Python - 熊猫 - 导入熊猫时出错
- python - 从二值化图像创建平方轮廓