Skip to content

CodeModeler Query Language (CMQL) CMQL operators

Simon Mourier edited this page Feb 19, 2020 · 1 revision

CMQL supports operators such as:

  • unary operators: not, exists

  • binary operators: and, or, equals, contains, freetext, like, & , |, , /,* +, -, =, <>, >=, <=, >, <

  • set operator: in (expression1, expression2, ... , expressionM)

This article provides examples for each of these operators.

Unary Operators

Those operators are useful if you want to load all line where a column is null or non null. For instance, this example loads all menus having a parent menu:

The not operator can be used to reverse the following predicate:

Note: Parenthesis are optional and where specified for readability.

Binary Operators

The most common ones are and and or, which are very straight forward to use:

Note: As you can see in the example above, types of arguments passed to the method don't have to be specified since they correspond to properties declared on the current entity. Writing CMQL methods this way allows to have a very flexible model since arguments types will automatically be updated if its related property type was changed.

Equality and Inequality Operators

Equality and inequality operators (=, <>, >=, <=, >, <) allow you to compare values between one another.

Note: Since angle brackets are a reserved character in XML, they must be used under their escaped form in an XML CodeModeler model, if edited by hand (outside of Visual Studio).

Here's a set of examples:

Equality and inequality operators also exist under their literal form:

  • =: equals, or is equal to

  • <>: not equals, or is not equal to

  • >: greaterthan, or is greater than

  • >=: is greater than or equal to, is greater than or equal, greaterthanorequal, or greaterthanorequalto

  • <: lesserthan, or is lesser than

  • <=: is lesser than or equal to, is lesser than or equal, lesserthanorequal, or lesserthanorequalto

Note: To test an inequality, '!=' is also supported.

String Operators

Available operators are equals ('=' is also supported), contains, freetext and like ('is like', 'starts with', 'startswith' and '#' are also supported).

Note: Desired column must have a Full-Text index defined in some way (depending on the persistence producer) to be used with the Freetext and Contains operators.

Set Operator

Using the in operator you can exclude values that aren't included in a list. For instance:

The in operator can also be used with dynamic parameters:

Furthermore, if sending a string array as a parameter, the in parameter can be used to filter values by the passed array:

Note: the previous method uses an out-of-the-box feature of the SQL Server Producer. Therefore, as of today, it's not supported by other persistence producers.

Top

There isn't a TOP operator in CMQL, however top is supported on method through the “Maximum Count” attribute on methods:

Top - Picture 291

Clone this wiki locally