Search code examples
asp.net-web-apiodatawcf-data-services

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.


Solution

  • 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.