Show/Hide Toolbars

TMS XData Documentation

The $filter query option can be used in a URI query string to specify a predicate by which entities will be filtered from an entity set. The $filter option only applies when addressing entity sets. The filter format is the following:

 

$filter=<boolean expression>

 

where <boolean expression> is a boolean expression with the predicate. Example:

 

http://server:2001/tms/xdata/Customer?$filter=Name eq 'John'

 

Properties can be accessed through their name, as in the previous example. The properties available are the ones from the entity type of the specified entity set. In the previous example, the entity set being retrieved contains instances of entity type Customer, which means properties of Customer are directly accessible in the boolean expression.

 

To access a property of an associated entity (navigation property), you can use slashes to build the path to the property name. The following example retrieves all customers which country is USA:

 

http://server:2001/tms/xdata/Customer?$filter=Country/Name eq 'USA'

 

You can use logical operators and parenthesis to define multiple expressions and change evaluation order:

 

http://server:2001/tms/xdata/Customer?$filter=(Name eq 'John' or Name eq 'Jack') and Country/Name eq 'USA'

 

The previous examples use string literals in the expressions. String literals are always defined using single quotes. You can have literals of other types in the expression. Since the filter query option is part of URL, you must always format the literals according to the rules defined in Literals in URI section.

 

The following table lists the operators supported in filter expressions, and the order of precedence from highest to lowest. Operators in the same category have equal precedence.

 

Category

Expression

Description

Grouping

(x)

Enclosing parenthesis - expressions are evaluated with higher precedence

Primary

Name/SubName

Slash, allowing access to a sub property (navigation property)

Unary

-x

Negate x

Unary

not x

Logical not applied to x

Multiplicative

x mul y

Multiplies x by y

Multiplicative

x div y

Divides x by y

Additive

x add y

Adds x and y

Additive

x sub y

Subtracts y from x

Relational

x lt y

Evaluates true if x is lower than y

Relational

x gt y

Evaluates true is x is greater than y

Relational

x le y

Evaluates true if x is lower than or equal to y

Relational

x ge y

Evaluates true if x is greater than or equal to y

Equality

x eq y

Evaluates true if x is equal to y

Equality

x ne y

Evaluates true is x is not equal to y

AND Condition

x and y

Evaluates true is both x and y are true

OR Condition

x or y

Evaluates true is either x or y are true