-
Notifications
You must be signed in to change notification settings - Fork 0
CodeModeler Query Language (CMQL) CMQL operators
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.
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.
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 (=, <>, >=, <=, >, <) 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.
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.
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.
There isn't a TOP operator in CMQL, however top is supported on method through the “Maximum Count” attribute on methods:
- Introduction
- Architect Guide
- Concepts
- Using Visual Studio
- Overview
- Creating a CodeModeler Project
- Visual Environment
- Project Hierarchy
- Design Surface
- Customizing Design Surfaces
- Ribbon Bar
- Property Grid
- Member Format Expressions
- Model Grid
- Method Editor
- View Editor
- Instance Editor and Grid
- Resources Editor
- Inferred Model Viewer
- Building
- Project Physical Layout
- Source Control Support
- Generating
- Aspect Oriented Design (AOD)
- Developer Guide
- The Business Object Model (BOM)
- CodeModeler Query Language (CMQL)
- Starting Guide - Tutorial
- Upgrade From CFE