azure cosmos db selecting min(int字段)返回0

brgchamk  于 2021-07-29  发布在  Java
关注(0)|答案(1)|浏览(330)

对azure cosmos db集合执行以下sql查询时,总是从c代码返回0。

SELECT value min([integer field]) FROM c

在azure门户-数据资源管理器上运行上述查询时,有时它会返回该特定字段的预期数值,而有时则返回0。
我不是故意共享代码,因为奇怪的行为是,当对cosmos db上的不同集合(使用相同的模式)执行相同的查询时,问题是没有复制。

jfewjypa

jfewjypa1#

你可以下载我的演示进行测试。
我当地宇宙的数据。

本地查询。 https://localhost:8081/_explorer/index.html .

按c代码查询。

Console.WriteLine("Beginning operations...\n");
            CosmosClient client = new CosmosClient("https://localhost:8081/", "C2***w==");
            Database database = await client.CreateDatabaseIfNotExistsAsync("ToDoList");
            Container container = database.GetContainer("jason");
            // Query for an item
            FeedIterator <dynamic> feedIterator =  container.GetItemQueryIterator<dynamic>("SELECT value MIN(c.age) from c");
            while (feedIterator.HasMoreResults)
            {
                FeedResponse<dynamic> response = await feedIterator.ReadNextAsync();
                foreach (var item in response)
                {
                    Console.WriteLine(item);
                }
            }

相关问题