Skip to content

problem with $apply and $orderby #420

@MolallaComm

Description

@MolallaComm

It appears the group by issues discussed in #76 are partially fixed using efcore6, .net core 6, and latest odata which is good news. If I do just a simple group by:

/odata/Item?$apply=groupby((ComponentID),aggregate($count%20as%20GroupCount))&$count=true

it works. If I tack an $orderby on the end however, it stops working:

/odata/Item?$apply=groupby((ComponentID),aggregate($count%20as%20GroupCount))&$count=true&$orderby=ComponentID

Yields:

The query specified in the URI is not valid. The given model does not contain the type 'Microsoft.AspNetCore.OData.Query.Wrapper.AggregationWrapper'

I can see on line 54 of QueryBinderContext.cs where it is looking for that AggregationWrapper in my model, and it obviously isn't there. If I comment that out, it gets further, but then pukes with:

Instance property 'ComponentID' is not defined for type 'Microsoft.AspNetCore.OData.Query.Wrapper.AggregationWrapper'

It seems like the basic expression processing is smart enough to deal with AggregationWrapper, but the orderby expression processing code is not. This worked in 3.1 as long as your controller pulled everything into memory first using something like:

            if (Request.QueryString.Value != null && Request.QueryString.Value.Contains("$apply"))
                return db.Item.ToList().AsQueryable();
            else
                return db.Item;

That fix no longer works in latest however which has me bummed as we use $apply with $orderby a lot.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions