You can construct a criteria expression to find objects in the Operations Manager database. The following sections provide syntax reference information that is useful when you are creating a criteria expression that includes any of the following elements:
- Comparison operators
- Wildcard characters
- DateTime values
- Integer enumeration values
Comparison Operators
You can use comparison operators when you are constructing a criteria expression. The valid operators are described in the following table.
Operator | Description | Examples | ||
---|---|---|---|---|
=, == |
Evaluates to true if the left and right operand are equal. |
|
||
!=, <> |
Evaluates to true if the left and right operand are unequal. |
|
||
> |
Evaluates to true if the left operand is greater than the right operand. |
|
||
< |
Evaluates to true if the left operand is less than the right operand. |
|
||
>= |
Evaluates to true if the left operand is greater than or equal to the right operand. |
|
||
<= |
Evaluates to true if the left operand is less than or equal to the right operand. |
|
||
LIKE |
Evaluates to true if the left operand matches the pattern that is defined by the right operand. Use the characters in the wildcard table in this topic to define the pattern. |
Evaluates to true if the Name value is "SQLEngine."
Evaluates to true if the Name value is "MySQLEngine." |
||
MATCHES |
Evaluates to true if the left operand matches the regular expression that is defined by the right operand. For information about and examples of regular expression syntax, see the MSDN topic, . |
Evaluates to true if the Name value is "SQL2005." |
||
IS NULL |
Evaluates to true if the value of the left operand is null. |
Evaluates to true if the ConnectorId property does not contain a value. |
||
IS NOT NULL |
Evaluates to true if the value of the left operand is not null. |
Evaluates to true if the ConnectorId property contains a value. |
||
IN |
Evaluates to true if the value of the left operand is in the list of values that are defined by the right operand.
|
Evaluates to true if the value of the Id property is one of the two globally unique identifiers provided in the expression. |
||
AND |
Evaluates to true if the left and right operands are both true. |
|
||
OR |
Evaluates to true if either the left or right operand is true. |
|
||
NOT |
Evaluates to true if the right operand is not true. |
|
Wildcard Characters
The following table defines the wildcard characters you can use to construct a pattern when using the LIKE operator.
Wildcard | Description | Example | ||
---|---|---|---|---|
% |
A wildcard that matches any number of characters. |
Evaluates to true if the Name value is "SQLEngine."
Evaluates to true if the Name value is "MySQLEngine." |
||
_ |
A wildcard that matches a single character. |
Evaluates to true for the following Name values: "SQL2000" "SQL2005"
|
||
[] |
A wildcard that matches any one character that is enclosed in the character set.
|
Evaluates to true for the following Name values: "SQL2000" "SQL2005" The expression evaluates to false for "SQL2003." |
||
[^] |
A wildcard that matches any one character that is not enclosed in the character set. |
Evaluates to true for "SQL2003." The expression evaluates to false for "SQL2000" and "SQL2005." |
DateTime Values
When you use a DateTime value in a query expression, use the general DateTime format ("G") to convert the DateTime value to a string value. For example,
string qStr = "TimeCreated <= '" + myInstant.ToString("G") + "'"; ManagementPackCriteria mpCriteria = new ManagementPackCriteria(qStr);
Integer Enumeration Values
When you use an integer enumeration value in a query expression, cast the enumeration value to an integer, for example:
string qStr = "Severity > " + (int)ManagementPackAlertSeverity.Warning; MonitoringAlertCriteria alertCriteria = new MonitoringAlertCriteria(qStr);