Querying Data
Basic Examples
OData supports various kinds of query options for querying data. This section will help you go through the common scenarios for these query options.
System Query Option $filter
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.
Basic predicates, built-in functions
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 OData V4 URL Conventions Document.
The request below uses $filter to get Batches with Name "Template Execution".
GET http://portal.xpertdoc.com/odata4/v6/Batches?$filter=Name eq 'Template Execution'
System Query Option $orderby
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 uses $orderby to get Batches ordered by their CreatedDate in a descending order
GET http://portal.xpertdoc.com/odata4/v6/Batches?$orderby=CreatedDate desc
The request below uses both previous $filter and $orderby to get Batches with Name "Template Execution" ordered by their CreatedDate in a descending order
GET http://portal.xpertdoc.com/odata4/v6/Batches?$filter=Name eq 'Template Execution'&$orderby=CreatedDate desc
More information at http://www.odata.org/getting-started/basic-tutorial/#queryData
Updated less than a minute ago