I've run into an issue with trying to sort my data coming from an OData service when the '$orderby' field is a 'LocalDate' type. I'm able to execute a LINQ DB query with a LocalDate field in an OrderBy statement, no problem, so the problem appears to be with the OData handling of the request itself, not DB related (RavenDB in this case). The error I'm getting is:
message: The query specified in the URI is not valid
exceptionMessage: The $orderby expression must evaluate to a single value of primitive type.
exceptionType: Microsoft.Data.OData.ODataException
stackTrace: at Microsoft.Data.OData.Query.OrderByBinder.ProcessSingleOrderBy(BindingState state, OrderByClause thenBy, OrderByToken orderByToken)
at Microsoft.Data.OData.Query.OrderByBinder.BindOrderBy(BindingState state, IEnumerable`1 orderByTokens)
at Microsoft.Data.OData.Query.ODataUriParser.ParseOrderByImplementation(String orderBy, IEdmType elementType, IEdmEntitySet entitySet)
at Microsoft.Data.OData.Query.ODataUriParser.ParseOrderBy(String orderBy, IEdmType elementType, IEdmEntitySet entitySet)
at Microsoft.Data.OData.Query.ODataUriParser.ParseOrderBy(String orderBy, IEdmModel model, IEdmType elementType)
at System.Web.Http.OData.Query.OrderByQueryOption.get_OrderByClause()
at System.Web.Http.OData.Query.OrderByQueryOption.get_OrderByNodes()
at System.Web.Http.OData.Query.ODataQueryOptions.EnsureStableSortOrderBy(OrderByQueryOption orderBy, ODataQueryContext context)
at System.Web.Http.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, ODataQuerySettings querySettings)
at System.Web.Http.QueryableAttribute.ApplyQuery(IQueryable queryable, ODataQueryOptions queryOptions)
at System.Web.Http.QueryableAttribute.ExecuteQuery(IEnumerable query, HttpRequestMessage request, HttpActionDescriptor actionDescriptor)
at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
My current workaround requires converting the LocalDate field to a string, which is certainly not ideal. Is there some workaround to be able to issue an $orderby command via OData on a LocalDate type field or is it really locked down to only allow primitive types (string, decimal, date, etc)?