【发布时间】:2025-11-21 09:10:02
【问题描述】:
我尝试在 c# 中 documentdb 下的 IDocumentQuery 查询中使用 OrderBy。
我尝试按距离我所在位置的距离检索课程列表,因此:
var userQuery = _client
.CreateDocumentQuery<Course>(_uriCourseCollection, options)
.Where(x => x.CourseName.ToLower().Contains(text))
.OrderBy(x =>x.GeoLocation.Location.Distance(myPoint))
.AsDocumentQuery();
我收到以下错误消息:
"不支持 ORDER BY 子句。无法使用 ORDER BY 项表达式 映射到文档路径"
有人可能有解决方案? ,还是以有效方式解决查询的解决方法?
【问题讨论】:
-
你引用过这个document吗?
Azure Cosmos DB returns an error when a query uses Order By but does not have a range index against the queried path with the maximum precision.Order By queries by default also require maximum index precision (-1). DataType can be String or Number
标签: c# sql linq azure azure-cosmosdb