OData supports various kinds of query options for querying data. This section will help you go through the common scenarios for these query options.
The $filter system query option allows clients to filter a collection of resources that are addressed by a request URL.
The expression specified with
$filter is evaluated for each resource in the collection, and only items where the
expression evaluates to true are included in the response.
There are several kinds of basic predicates and built-in functions for
$filter, including logical operators and
arithmetic operators. For more detailed information, please refer to the OData protocol (opens new window) document.
The request below uses
$filter to get people with FirstName "Scott".
The $orderby system query option allows clients to request resources in either ascending order using asc or descending order using desc. If asc or desc not specified, then the resources will be ordered in ascending order. The request below orders People on property LastName in descending order.
# $top and $skip
The $top system query option requests the number of items in the queried collection to be included in the result. The $skip query option requests the number of items in the queried collection that are to be skipped and not included in the result. The request below returns the first two people of the People entity set.
The request below returns people starting with the 2nd person of the entity set People
The $count system query option allows clients to request a count of the matching resources included with the resources in the response. The request below returns the total number of people in the collection.
The $expand system query option specifies the related resources to be included in line with retrieved resources. The request below returns people with navigation property Passengers of a Flight
The $select system query option allows the clients to requests a limited set of properties for each entity or complex type. The request below returns origin and destination of all flights:
The $search system query option restricts the result to include only those entities matching the specified search expression. The definition of what it means to match is dependent upon the implementation. The request below gets all airports that have 'fo' or 'lh' in their code.
# Lambda Operators
OData defines two operators
all that evaluate a Boolean expression on a collection.
They can work on either collection properties or collections of entities.
The request below returns the People that have Pets with property 'Name' ending with 'The Dog'.