Search code examples
odatamodeling

OData: Query with embedded table/entity set?


I have some problems modelling an OData Service. My requirement is, that I want to query an Entity Set by a list of single values and/or ranges. Example: Give me all Entities from the Entity Set where the ID is 3, 6, 8, between 14 and 20 or between 35 and 77.

How could that be modelled? I thought of a Function Import, but I am not sure if a entity set (=the list of values/ranges) can be used as parameter there!?

Thanks in advance for your help!


Solution

  • You should be able to do this with OData's built-in filtering mechanism, the $filter query string parameter.

    For example, the request URI would look something like this:

    http://.../MyService.svc/EntitySet?$filter=ID eq 3 or ID eq 6 or ID eq 8 or (ID ge 14 and ID le 20) or (ID ge 35 and ID le 77)