For the Simplified Chinese translation, click 中文译文.
This is a list of query options for OData.
We currently only support the options described here.
2 Retrieving Objects
2.1 Retrieving All Objects
All objects can be retrieved by specifying the URI. For example:
/odata/myservice/myresource. You can see this if you specify the URI in a browser.
2.2 Retrieving a Single Object
A single object can be retrieved by passing the object identifier in the URI. For example:
2.3 Retrieving Associated Objects
Associated objects can be retrieved by passing the
$expand query parameter. For example:
$expand feature was introduced in Studio Pro 8.11.0.
3 Counting the Number of Objects
3.1 Retrieving a Count of Objects
You can find out how many objects there are by passing the
$count query option. In this case, the result is an integer which is the number of objects. For example:
3.2 Inline Count
By setting the
$inlinecount query option to ‘allpages’, a count of the number of items returned will be included in the result. For example:
Filters are applied by appending a
$filter=... parameter to the request. For example:
/Employees?$filter=Name eq 'John'.
4.1 Passing attributes
This table describes how to pass values for different attribute types:
|Type||How to Pass|
|String and Enumeration||Enclosed in single quotes (for example, ‘John’)|
|Other||Plain value (for example, 15)|
4.2 Comparison Operators
We support the following comparison operators:
|ne||does not equal||
|ge||greater than or equal to||
|le||less than or equal to||
4.3 Arithmetic Operators
||All products with price 8|
||All products with price 12|
||All products with price 5|
||All products with price 20|
||All products with price divisible by 5|
||All employees with names that contain an ‘f’|
||All employees with names that end with ‘f’|
||All employees with names that start with ‘f’|
||All employees with names that have a length of 5|
||All employees born in the year 1990|
||All employees born in May|
||All employees born on the 31st day of the month|
||All employees registered between 13:00 (1 PM) and 13:59 (1:59 PM)|
||All employees registered on the 55th minute of any hour|
||All employees registered on the 55th second of any minute of any hour|
4.5 Combining Filters
Filters can be combined with
(). For example:
?$filter=Name eq 'John' and (Age gt 65 or Age lt 11).
4.6 Filtering by Association
You can filter on attributes of an associated entity. The way you do this depends on whether the association exposes one object or a list of objects.
|Filter on an associated object||
|Filter on an associated list||
You can sort the result using the
$orderby query option. For example:
The default direction is ascending, and you can make this explicit. For example:
You can also order the result in a descending direction. For example:
It is possible to sort on multiple attributes, which have to be comma-separated. For example:
?$orderby=Name asc,Age desc.
6 Selecting fields
You can select which attributes and associations to return by specifying the
$select query option. For example:
7.1 Top (Limit)
You can limit the number of returned objects using the
$top query option, where the limit is a positive integer. For example:
7.2 Skip (Offset)
You can skip a number of objects before retrieving the result using the
$skip query option, where the offset is a positive integer. For example:
?$skip=100 will return objects starting with the 101st object in the list.
8 Null Literals
You can compare values against the
null literal. For example:
?$filter=Name eq null.
In this example,
Name is a string attribute that can have no assigned value in the database. Note that
null means no value as opposed to
'' (which is an empty string).
When you filter against associations, null literals can be quite useful. For example:
?$filter=Association_A_B ne null. In this example, you query for objects of entity type
A that have at least one association set to objects of entity type