OData Query Options

3 minutes to read Download PDF Edit

This is a list of query options for OData. Note that when something is not in this list, we currently don’t support it (yet).

Retrieving a single object

This can be done by passing the identifier in the uri. For example: /odata/myservice/myresource(8444249301330581)

Retrieving a count of objects

This can be done by passing the $count query option. In this case the result is just the number of objects. For example: /odata/myservice/myresource/$count

Inline count

By setting the $inlinecount query option to ‘allpages’, an inline count will be added to the result. For example: ?$inlinecount=allpages


At the moment we only support basic filtering options.

This is done by passing parameters to the request, for example ?$filter=Name eq ‘John’

We support the following operators:

eqequals?$filter=Name eq 'John'
nenot equals?$filter=Name ne 'John'
gtgreater than?$filter=Age gt 15
ltless than?$filter=Age lt 15
gegreater than or equals to?$filter=Age ge 15
leless than or equals to?$filter=Age le 15

How to pass values for different attribute types

TypeHow to pass
String and EnumerationSurrounded with apostrophes, e.g. 'John'
DatetimeSurrounded with datetime and apostrophes, e.g. datetime'2015-01-01' or datetime'<epoch value here>'
OtherPlain value, e.g. 15

Combining filters

Filter can be combined with ‘and’ and ‘or’, ‘not’ and (), so for example ?$filter=Name eq ‘John’ and (Age gt 65 or Age lt 11)

and?$filter=Name eq 'John' and Age gt 65
or?$filter=Age gt 65 or Age lt 11
not?$filter=not(Name eq 'John')
()?$filter=Name eq 'John' and (Age gt 65 or Age lt 11)


You can sort the result using the $orderby query option. For example: ?$orderby=Name

The default direction is ascending, you can pass this to make it explicit. For example: ?$orderby=Name asc

You can also order the result in a descending direction. For example: ?$orderby=Name desc

It’s possible to sort on multiple attributes, these have to be comma separated. For example: ?$orderby=Name, Age desc

Select fields

You can select which attribute and association to return by specifying $select query option. For example: ?$select=Name, Age

Top (limit)

Limiting the amount of returned objects can be done using the $top query option, where the value is a positive integer. For example: ?$top=100

Skip (offset)

Skipping a number of objects in the result can be done using the $skip query option, where the value is a positive integer. For example: ?$skip=100

Null literals

Operators can compare against ‘null’ literals. For example: ?$filter=Name eq null 

In this example, Name is a string attribute which can have a ‘null’ 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_AB ne null 

In this example, you query for objects A that actually have an association set to B objects.

Copyright © Mendix. All rights reserved. | Mendix.com | Terms of Use | Privacy Policy