-
Type: Bug
-
Resolution: Cannot Reproduce
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.9.1
-
Component/s: None
-
None
-
Environment:Azure cloud (Windows)
I am using OData against the MongoDB IQueryable collection and it works fine but when I try to sort by a nullable field it breaks with: only fields are allowed in a $sort when ordering by a nullable field
If I convert that field to not nullable it works fine.
api/TimeTracking/ItemType?$orderBy=ModifiedAt => error when nullable
api/TimeTracking/ItemType?$orderBy=ModifiedAt => working when not nullable
IMongoQueryable<T> query = queryOptions == null? entities.AsQueryable() : queryOptions.ApplyTo(entities.AsQueryable()) as IMongoQueryable<T>;
Error:
Exceptions.ErrorHandlingMiddleware:Error: Only fields are allowed in a $sort.
System.NotSupportedException: Only fields are allowed in a $sort.
at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateOrderBy(OrderByExpression node)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslatePipeline(PipelineExpression node)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node, IBsonSerializerRegistry serializerRegistry, ExpressionTranslationOptions translationOptions)
at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
at MongoDB.Driver.Linq.MongoQueryableImpl`2.ToCursorAsync(CancellationToken cancellationToken)
at MongoDB.Driver.IAsyncCursorSourceExtensions.ToListAsync[TDocument](IAsyncCursorSource`1 source, CancellationToken cancellationToken)
{{}}
Did anyone have a similar experience? Is there a workaround for this?
{{}}
Nuget:
{{}}
- Microsoft.AspNetCore.OData v:7.1.0
- MongoDB.Driver v:2.9.1
{{}}
- duplicates
-
CSHARP-3965 OrderBy with an expression that doesn't resolve to a field is not supported
- Closed