nboukeffa
nboukeffa

Reputation: 127

OData V4 - Expand and options (filter, top, ...)

I'm using OData V4 with ASP WebApi. I would filter an expanded collection as the new version of OData can do (http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part2-url-conventions.html - Example 90) but in my case the filter option has no effect.

I also tried to do the same thing with the Nortwhind service and the TripPin service. It works for the TriPin service, but not for Northwind service.

Here, the requests that I used :

My Service : api/odata/Customers(19037)?$expand=orders($filter=id+eq+1796) --> Doesn't work

Northwind Service : http://services.odata.org/V4/Northwind/Northwind.svc/Customers?$expand=Orders($filter=OrderID+eq+10643) --> Doesn't work

TripPin Service : http://services.odata.org/V4/TripPinServiceRW/People?$expand=Trips($filter=TripId+eq+1001) --> Does Work

Thanks for your help.

Upvotes: 1

Views: 3213

Answers (2)

Feng Zhao
Feng Zhao

Reputation: 2995

This is a feature we don't support for now.

The root cause is that the inline $filter is ignored while translating $expand.

Check method "GetPropertiesToExpandInQuery" of SelectExpandBinder.cs:

https://aspnetwebstack.codeplex.com/SourceControl/latest#src/System.Web.OData/OData/Query/Expressions/SelectExpandBinder.cs

Only expandItem.SelectAndExpand is returned while other options are ignored.

So only $select and $expand inside $expand work for now.

I have investigated how to fix it before, but since the issue is not approved, please vote the issue Jinfu opened to draw more attention of lead team.

Upvotes: 1

Tan Jinfu
Tan Jinfu

Reputation: 3345

I reproduced the issue, and found $select inside a $expand works well. I believe this is a defect and opened a bug for it: https://aspnetwebstack.codeplex.com/workitem/2070.

Upvotes: 1

Related Questions