Framework:Syntax of expressions: Difference between revisions
Created page with 'When creating an expression, the ColumnName property refers to columns. If e. g. the ColumnName of one column is “UnitPrice” and of another column “Quantity”, the followi…' |
No edit summary |
||
| Line 38: | Line 38: | ||
'''Total * [Column[\]]''' | '''Total * [Column[\]]''' | ||
(Only the second bracket must be provided with an escape character.) | (Only the second bracket must be provided with an escape character.) | ||
User defined values | |||
===User defined values=== | |||
User defined values can be used in expressions and be compared with column values. Character string values must be put in simple quotation marks. Date values must be put in number characters (#). Decimal values and scientific styles of writing are admissible for numeric values. | User defined values can be used in expressions and be compared with column values. Character string values must be put in simple quotation marks. Date values must be put in number characters (#). Decimal values and scientific styles of writing are admissible for numeric values. | ||
Example: | Example: | ||
| Line 44: | Line 46: | ||
"Price <= 50.00" | "Price <= 50.00" | ||
"Birthdate < #1/31/82#" | "Birthdate < #1/31/82#" | ||
In the case of columns with enumeration values, please change the value into an integer data type. Example: | In the case of columns with enumeration values, please change the value into an integer data type. Example: | ||
"EnumColumn = 5" | "EnumColumn = 5" | ||
Operators | |||
A linkage with the Boolean operators AND, OR and NOT is permissible. By means of brackets you can group clauses and enforce priority. The AND operator has priority over other operators. Example: | ===Operators=== | ||
A linkage with the Boolean operators AND, OR and NOT is permissible. By means of brackets you can group clauses and enforce priority. The AND operator has priority over other operators. | |||
Example: | |||
(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John' | (LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John' | ||
When creating relational expressions, the following operators are admissible: | When creating relational expressions, the following operators are admissible: | ||
< | |||
:<nowiki><</nowiki> | |||
:<nowiki>></nowiki> | |||
:<nowiki><=</nowiki> | |||
:<nowiki>>=</nowiki> | |||
:<nowiki><></nowiki> | |||
:<nowiki>=</nowiki> | |||
:<nowiki>IN</nowiki> | |||
:<nowiki>LIKE</nowiki> | |||
The following arithmetic operators are also supported in expressions: | The following arithmetic operators are also supported in expressions: | ||
+ (Addition) | |||
Character String Operators | :<nowiki>+</nowiki> (Addition) | ||
:<nowiki>-</nowiki> (Subtraktion) | |||
:<nowiki>*</nowiki> (Multiplikation) | |||
:<nowiki>/</nowiki> (Division) | |||
:<nowiki>%</nowiki> (Modulo) | |||
===Character String Operators=== | |||
Please use the plus sign (+) to link a character string. Whether comparisons of characterstrings are case sensitive or not is determined ty the CaseSensitive property of the DataSet class. You may, however, overwrite this value by means of the CaseSensitive property of the DataTable class. | Please use the plus sign (+) to link a character string. Whether comparisons of characterstrings are case sensitive or not is determined ty the CaseSensitive property of the DataSet class. You may, however, overwrite this value by means of the CaseSensitive property of the DataTable class. | ||
Wildcard | Wildcard | ||
Both * and % may be used as wildcards in a LIKE comparison. If the character string in a LIKE clause contains * or %, the characters in brackets ([]) must be included as escape characters. If a bracket is contained in the clause, the parenthesis must be provided with brackets as escape characters (e. g. [[] or []]). A wildcard may be used both at the beginning and at the end of a sample, but may also be used just at the end or just at the beginning of a sample. | Both * and % may be used as wildcards in a LIKE comparison. If the character string in a LIKE clause contains * or %, the characters in brackets ([]) must be included as escape characters. If a bracket is contained in the clause, the parenthesis must be provided with brackets as escape characters (e. g. [[] or []]). A wildcard may be used both at the beginning and at the end of a sample, but may also be used just at the end or just at the beginning of a sample. | ||
Example: | Example: | ||
"ItemName LIKE '*product*'" | "ItemName LIKE '*product*'" | ||
"ItemName LIKE '*product'" | "ItemName LIKE '*product'" | ||
"ItemName LIKE 'product*'" | "ItemName LIKE 'product*'" | ||
Wildcards within a character string are not allowed. 'te*xt' for example is not permissible. | Wildcards within a character string are not allowed. 'te*xt' for example is not permissible. | ||
Functions | |||
===Functions=== | |||
The following functions are also supported: | The following functions are also supported: | ||
Convert | |||
'''Convert''' | |||
{| cellspacing="1" cellpadding="5" width={{{breite|60%}}} border="1" | |||
|- | |||
| width="100pt" style=background-color:#f6f6f6 |'''Description''' | |||
| Converts the indicated expression into specified .NET framework type. | |||
|- | |||
|style=background-color:#f6f6f6 | '''Syntax''' | |||
| Convert(expression, type) | |||
|- | |||
|style=background-color:#f6f6f6 | '''Arguments''' | |||
| expression- the expression to be converted. | |||
type- the .NET framework type into which the value is converted. | |||
|- | |||
| style=background-color:#f6f6f6 |'''Example''' | |||
| myDataColumn.Expression="Convert(total,'System.Int32')" | |||
|} | |||
Revision as of 10:30, 3 May 2010
When creating an expression, the ColumnName property refers to columns. If e. g. the ColumnName of one column is “UnitPrice” and of another column “Quantity”, the following expression results:
"[UnitPrice] * [Quantity]"
When creating an expression for a filter, character strings are included in simple quotation marks:
"LastName = 'Jones'"
The following characters are special characters and must – as described below – be provided with escape characters if they are to be used in the name of a column:
- ~
- (
- )
- #
- \
- /
- =
- >
- <
- +
- -
- *
- %
- &
- |
- ^
- '
- "
- [
- ]
If the name of a column contains one of the above-referenced characters, the name must be put in brackets. If e. g. you use a column named “Column#” in an expression, write "[Column#]":
Total * [Column#]
Since brackets are special characters you must use a backslash ("\") as escape character for the bracket if the latter is part of the column’s name. A column named "Column[]" will then be written as follows:
Total * [Column[\]] (Only the second bracket must be provided with an escape character.)
User defined values
User defined values can be used in expressions and be compared with column values. Character string values must be put in simple quotation marks. Date values must be put in number characters (#). Decimal values and scientific styles of writing are admissible for numeric values. Example: "FirstName = 'John'" "Price <= 50.00" "Birthdate < #1/31/82#"
In the case of columns with enumeration values, please change the value into an integer data type. Example: "EnumColumn = 5"
Operators
A linkage with the Boolean operators AND, OR and NOT is permissible. By means of brackets you can group clauses and enforce priority. The AND operator has priority over other operators.
Example:
(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'
When creating relational expressions, the following operators are admissible:
- <
- >
- <=
- >=
- <>
- =
- IN
- LIKE
The following arithmetic operators are also supported in expressions:
- + (Addition)
- - (Subtraktion)
- * (Multiplikation)
- / (Division)
- % (Modulo)
Character String Operators
Please use the plus sign (+) to link a character string. Whether comparisons of characterstrings are case sensitive or not is determined ty the CaseSensitive property of the DataSet class. You may, however, overwrite this value by means of the CaseSensitive property of the DataTable class. Wildcard
Both * and % may be used as wildcards in a LIKE comparison. If the character string in a LIKE clause contains * or %, the characters in brackets ([]) must be included as escape characters. If a bracket is contained in the clause, the parenthesis must be provided with brackets as escape characters (e. g. [[] or []]). A wildcard may be used both at the beginning and at the end of a sample, but may also be used just at the end or just at the beginning of a sample.
Example:
"ItemName LIKE '*product*'" "ItemName LIKE '*product'" "ItemName LIKE 'product*'"
Wildcards within a character string are not allowed. 'te*xt' for example is not permissible.
Functions
The following functions are also supported:
Convert
| Description | Converts the indicated expression into specified .NET framework type. |
| Syntax | Convert(expression, type) |
| Arguments | expression- the expression to be converted.
type- the .NET framework type into which the value is converted. |
| Example | myDataColumn.Expression="Convert(total,'System.Int32')" |