1
votes

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.

2
Just to be clear. Northwind Service is implemented using WCF data services and TripPin is implemented directly using ODL.QianLi
In some cases the use of the operator $expand is used to circumvent the OData limitations in terms of aggregation. For this kind of need, you can use my product AdaptiveLINQ which allows to expose an aggregation query via standard OData operators as $select and $filter.nlips

2 Answers

1
votes

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.

1
votes

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.