Operators

An operator is the part of a condition between the field and its value: Age is greater than 18. The Rule Editor offers only the operators that fit the data type of the field, so a rule author never sees starts with after a number. This page lists the operators of every data type, explains the ones that need explaining, and shows how to hide operators you do not want rule authors to use.

Operators by Data Type

The labels below are the editor's defaults in English. They come from the Help XML, so you can change or translate them; see Help XML & Multilingual Support.

Data type Operators
Numbers is equal to, is not equal to, is less than, is less than or equal to, is greater than, is greater than or equal to, is between, is not between, is in, is not in
Strings is, is not, contains, does not contain, starts with, does not start with, ends with, does not end with, is in, is not in
Dates is equal to, is not equal to, is before, is before or equal to, is after, is after or equal to, is between, is not between, is in, is not in
Times of day is equal to, is not equal to, is before, is before or equal to, is after, is after or equal to, is between, is not between, is in, is not in
Durations is equal to, is not equal to, is shorter than, is shorter than or equal to, is longer than, is longer than or equal to, is between, is not between, is in, is not in
Booleans is, is not
Enumerations is, is not, is in, is not in
Collections of values contain, do not contain, start with, do not start with, end with, do not end with, collection is empty, collection is not empty, count

Every nullable type, and a string, also has has no value and has any value. A collection of objects is queried with the Collections... menu instead: exists, does not exist, all, first, last, count and count with. See Collection Data Types.

In and Not In

is in and is not in compare a field with a list of values in one condition, such as Status is in (Active, Pending) or Zip Code is not in (30301, 30302, 30303). They work with numbers, strings, dates, times, durations, enumerations, and dynamic menu data sources.

  • The author adds values with Add another value, which disappears once every value of an enumeration or a data source is in the list.
  • A value listed twice is refused. Strings are compared the way the field compares them: with the default StringComparison.OrdinalIgnoreCase, a and A are the same value.
  • A list of an enumeration or a data source offers only the values that are not in it yet.

Between and Not Between

is between checks that a number, a date, a time, or a duration lies in a range, and includes both bounds: Age is between 18 and 65 holds for 18 and for 65. The first bound must be less than the second; equal bounds and reversed bounds are invalid, and the editor says so.

is not between is its exact opposite: it is true whenever is between is false, so a member or a bound with no value is not between.

Comparing Different Types

The operators compare compatible values of different types. Numbers of different types are converted to the wider of the two; see Automatic Numeric Type Conversion. A date field shown as a date only is compared by its date; a duration is compared only with a duration; see Dates and Times. Strings are compared as the field's StringComparison says.

Hiding Operators

Add an Operator to the ExcludedOperators collection of the Control to take operators away from one data type. ExcludedOperator is a set of flags, so one entry can hide several:

using CodeEffects.Rule.Common.Models;
using CodeEffects.Rule.Editor;

var editor = new Control("divEditor") { SourceType = typeof(Patient) };

// No "starts with" or "ends with" for strings
editor.ExcludedOperators.Add(new Operator
{
    Type = DataType.String,
    ExcludedOperator = ExcludedOperator.StartsWith | ExcludedOperator.EndsWith
});

// No ranges for numbers: is between and is not between have a flag each
editor.ExcludedOperators.Add(new Operator
{
    Type = DataType.Numeric,
    ExcludedOperator = ExcludedOperator.Between | ExcludedOperator.NotBetween
});

is not between is a separate operator with its own flag, ExcludedOperator.NotBetween. If your application hides Between, add NotBetween too, or rule authors will still be able to write a range with it. ExcludedOperator.Count hides count for collections of values.

Ask on Stack Overflow - Yes, it's still active
Ask in GitHub Discussions

p102

l097 --

l102

p101

×