Framework:Syntax of expressions

From CoPlanner 10
Jump to navigationJump to search

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')"