$apply in combination with $select not working
Combination of $apply and $select not working. According to http://docs.oasis-open.org/odata/odata-data-aggregation-ext/v4.0/cs02/odata-data-aggregation-ext-v4.0-cs02.html#_Toc435016590
3.16 Evaluating $apply The new system query option $apply is evaluated first, then the other system query options are evaluated, if applicable, on the result of $apply in their normal order (see [OData-Protocol, section 11.2.1]). If the result is a collection, $filter, $orderby, $expand and $select work as usual on properties that are defined on the output set after evaluating $apply.
Assemblies affected
Microsoft.aspNet.OData 7.0.1.20718
Reproduce steps
RutHWModelsView?$apply=groupby((description,hw_model,id))&$select=description,hw_model,id
Expected result
The select should work as the groupby returns a collection.
Actual result
"message": "Instance property 'description' is not defined for type 'Microsoft.AspNet.OData.Query.Expressions.AggregationWrapper'",
Additional detail
Optional, details of the root cause if known. Delete this section if you have no additional details to add.
@kosinsky Would please take a look this issue?
It's not implemented yet. Workaround is to just do "RutHWModelsView?$apply=groupby((description,hw_model,id))". Adding $select will not change query results
That's correct, the result is the same in that case. But I'm using a framework which automatically adds the $select to the query, as it normally should work according to the specs. Is this already in scope for one of the next releases? Thanks
Is there any progress on this?
This is the stack trace I get when attempting a query which contains a groupby and a select
{
"error": "System.ArgumentNullException",
"message": "Value cannot be null.\r\nParameter name: property",
"stackTrace": [
" at System.Linq.Expressions.Expression.Property(Expression expression, PropertyInfo property)\r",
" at Microsoft.AspNet.OData.Query.Expressions.SelectExpandBinder.CreatePropertyValueExpression(IEdmStructuredType elementType, IEdmProperty property, Expression source, FilterClause filterClause)\r",
" at Microsoft.AspNet.OData.Query.Expressions.SelectExpandBinder.BuildPropertyContainer(Expression source, IEdmStructuredType structuredType, IDictionary`2 propertiesToExpand, IDictionary`2 propertiesToInclude, ISet`1 autoSelectedProperties, Boolean isSelectingOpenTypeSegments)\r",
" at Microsoft.AspNet.OData.Query.Expressions.SelectExpandBinder.ProjectElement(Expression source, SelectExpandClause selectExpandClause, IEdmStructuredType structuredType, IEdmNavigationSource navigationSource)\r",
" at Microsoft.AspNet.OData.Query.Expressions.SelectExpandBinder.GetProjectionLambda(SelectExpandQueryOption selectExpandQuery)\r",
" at Microsoft.AspNet.OData.Query.Expressions.SelectExpandBinder.Bind(IQueryable queryable, SelectExpandQueryOption selectExpandQuery)\r",
" at Microsoft.AspNet.OData.Query.Expressions.SelectExpandBinder.Bind(IQueryable queryable, ODataQuerySettings settings, SelectExpandQueryOption selectExpandQuery)\r",
" at Microsoft.AspNet.OData.Query.SelectExpandQueryOption.ApplyTo(IQueryable queryable, ODataQuerySettings settings)\r",
" at Microsoft.AspNet.OData.Query.ODataQueryOptions.ApplySelectExpand[T](T entity, ODataQuerySettings querySettings)\r",
" at Microsoft.AspNet.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, ODataQuerySettings querySettings)\r",
" at Microsoft.AspNet.OData.EnableQueryAttribute.ApplyQuery(IQueryable queryable, ODataQueryOptions queryOptions)\r",
" at Microsoft.AspNet.OData.EnableQueryAttribute.ExecuteQuery(Object responseValue, IQueryable singleResultCollection, IWebApiActionDescriptor actionDescriptor, Func`2 modelFunction, IWebApiRequestMessage request, Func`2 createQueryOptionFunction)\r",
" at Microsoft.AspNet.OData.EnableQueryAttribute.OnActionExecuted(Object responseValue, IQueryable singleResultCollection, IWebApiActionDescriptor actionDescriptor, IWebApiRequestMessage request, Func`2 modelFunction, Func`2 createQueryOptionFunction, Action`1 createResponseAction, Action`3 createErrorAction)\r",
" at Microsoft.AspNet.OData.EnableQueryAttribute.OnActionExecuted(ActionExecutedContext actionExecutedContext)\r",
" at Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)\r",
" at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()\r",
" at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)\r",
" at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r",
" at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()\r",
" at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()"
]
}
Any updates on this? Will this be resolved, or do I need to find a work-around?
Guys, any update on this in the latest version? If not, what is the work-around?
same issue still there in Odata 8 , Net 6 , EF 6