gpt4 book ai didi

Azure DocumentDB - 查询不返回结果

转载 作者:行者123 更新时间:2023-12-02 23:51:03 25 4
gpt4 key购买 nike

Azure DocumentDB 是否支持以下查询?它不返回任何文档。

Variables values at runtime:
1. collectionLink = "<link for my collection>"
2. feedOptions = new FeedOptions { MaxItemCount = 2 }
3. name = "chris"

client.CreateDocumentQuery<T>(collectionLink, feedOptions).Where(m => (m.Status == "Foo" && (m.Black.Name == null || m.Black.Name != name) && (m.White.Name == null || m.White.Name != name)));

我已经使用更简单的查询进行了测试,如下所示,它们都返回我期望的结果。

client.CreateDocumentQuery<T>(collectionLink, feedOptions).Where(m => m.Status == "Foo");

client.CreateDocumentQuery<T>(collectionLink, feedOptions).Where(m => m.Status == "Foo").Where(m => m.Size == 19);

最后,我确保存在满足有问题查询的过滤条件的文档:

{
"id": "1992db52-c9c6-4496-aaaa-f8cb83a8c6b0",
"status": "Foo",
"size": 19,
"black": {
"name": "charlie"
},
"white": {},
}

谢谢。

最佳答案

事实证明“m.White.Name == null || m.White.Name != name”检查是有问题的,因为数据库中的文档中不存在“Name”字段。

当文档被编辑为以下内容时,查询将返回它。请注意“名称”字段的显式空值。

{
"id": "1992db52-c9c6-4496-aaaa-f8cb83a8c6b0",
"status": "Foo",
"size": 19,
"black": {
"name": "charlie"
},
"white": {
"name": null
},
}

关于Azure DocumentDB - 查询不返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26989290/

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