SqlFilter.SqlExpression Property
Gets the SQL expression.
Namespace: Microsoft.ServiceBus.Messaging
Assembly: Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)
The following information describes the possible values for the SqlExpression property. A valid predicate is defined as follows. These values align with SQL92 standard and T/SQL:
<predicate ::=
{ NOT <predicate> }
| <predicate> AND <predicate>
| <predicate> OR <predicate>
| <expression> { = | <> | != | > | >= | < | <= } <expression>
| <property> IS [NOT] NULL
| <expression> [NOT] IN ( <expression> [, ...n] )
| <expression> [NOT] LIKE <pattern> [ESCAPE <escape_char>]
| EXISTS ( <property> )
| ( <predicate> )
<expression> ::=
<constant>
| <property>
| <expression> { + | - | * | / } <expression>
| { + | - } <expression>
| ( <expression> )
Syntax
<property> := [<scope> .] <property_name>
Arguments
Remarks
An attempt to access a non-existent system property is an error. An attempt to access a non-existent user property is not an error. Instead, the non-existing user property is evaluated as an unknown value. An unknown value is treated specially during operator evaluation.
Syntax
<property_name> ::= <property_name_part> <scope> ::= <property_name_part> <property_name_part> ::= <identifier> | <delimited_identifier> <identifier> ::= <regular_identifier> | <quoted_identifier> | <delimited_identifier>
Arguments
Syntax
<pattern> ::= <expression>
Remarks
<pattern> must be an expression that is evaluated as a string. It is used as a pattern for the LIKE operator, and can contain the following wildcard characters:
%: Any string of zero or more characters.
_: Any single character.
Syntax
<escape_char> ::= <expression>
Remarks
<escape_char> must be an expression that is evaluated as a string of length 1. It is used as an escape character for the LIKE operator. For example, property LIKE 'ABC\%' ESCAPE '\' matches ABC% rather than a string that starts with "ABC".
Syntax
<constant> ::= <integer_constant> | <decimal_constant> | <approximate_number_constant> | <boolean_constant> | NULL
Arguments
Syntax
<boolean_constant> := TRUE | FALSE
Remarks
Boolean constants are represented by the keyword TRUE or FALSE. The values are stored as System.Boolean.
Syntax
<string_constant>
Remarks
String constants are enclosed in single quotation marks and include any valid Unicode characters. A single quotation mark embedded in a string constant is represented as two single quotation marks.
Note the following semantics for SqlFilter:
Property names are case-insensitive.
“IS NULL” returns true if the property doesn’t exist or if the property’s value is null. To check if a property exists, use the EXISTS keyword. For example, the following will return true if aProperty exists:
EXISTS(aProperty)
When a property name is used as part of any expression, its value becomes “unknown” if the property does not exist. Any arithmetic operator (for example, +) returns an “unknown” value if any operand is unknown. For example, the following is “unknown” if aMissingProperty is missing:
aMissingProperty + “abc”
Any comparison operators return “unknown” if any operand’s value is evaluated to “unknown”. For example:
aMissingProperty > anExistingProperty
The above expression always returns “unknown” if aMissingProperty does not exist.
Any logical operators consider three internal values as valid conditions: “true”, “false” and “unknown.” The following table describes these operators’ truth values (T, F, U each represents “true”, “false” and “unknown”):
AND
T
F
U
T
T
F
U
F
F
F
F
U
U
F
U
OR
T
F
U
T
T
T
T
F
T
F
U
U
T
U
U
NOT
-
T
F
F
T
U
U
EXISTS and LIKE return “unknown” if any operand is “unknown.” IN returns “unknown” if the left operand is “unknown.”
You can no longer specify a GUID as a valid literal. However, you can still write them in a string literal and you can expect implicit conversion when you assign the value to GUID type property.
Non-logical operators (such as +, -, * and /) now behave in the same way as the C# operator binding. You should expect exactly the same behavior as C#, except for the “unknown” value handling mentioned above.
A filter action assignment operator attempts to perform an implicit conversion if an implicit conversion exists, if the left side of a property exists and its value is not null. The exact behavior follows what the System.Convert.ChangeType() function does in the CLR, in addition to some implicit conversions of DateTimeOffset, TimeSpan, Guid, and Uri between strings.
Note