Parameters and an example of a function FuncIN

FuncIN the same function as the equality comparison in SQL Builder function limitations SQLWhereLanguageDef.

Parameters GetFunction

GetFunction takes one parameter: an array of variable definition (Variable Def) and the objects among which the search is performed.

Example usage

Let’s consider an example. Required to deduct all Кредиты issued special clients, the list of keys which are known to us.

The SQL statement would look as follows:

SELECT * FROM Кредиты WHERE Клиент IN ('{IDList}')@@
Где {IDList} - список [Primary-keys-objects|первичных ключей) искомых `Клиентов`

SQLWhereLanguageDef:

List<Клиент> клиенты = new List<Клиент>();
SQLWhereLanguageDef langdef = SQLWhereLanguageDef.LanguageDef;
List<object> clientKeys = new List<object>();
clientKeys.Add(new VariableDef(langdef.GuidType, Information.ExtractPropertyPath<Кредит>(x => x.Клиент)));

foreach (var клиент in клиенты)
	clientKeys.Add(клиент.__PrimaryKey);

Function lf = langdef.GetFunction(langdef.funcIN, clientKeys.ToArray());

Features string comparison

The fact that MS SQL Sever follows the standard ANSI 92 SQL in regard to string comparisons.

To determine whether strings of unequal length, especially on the right side the shorter string adds spaces, so the string lengths become equal.

Then the symbols in the first string are compared with characters of the second with regard to their location. If not equal at least one pair, the strings are considered unequal.

This applies to comparisons such as WHERE strfield = ‘…’, or HAVING strfield=’…’, or strfield IN (‘…’, ‘…’, …). In these cases, the string ‘abc’ and ‘abc’ are considered equal.

The exception is the operator LIKE (WHERE strfield LIKE ‘…’), for it is the string ‘abc’ and ‘abc’ is different, therefore, to impose restrictions on the lines, instead of FuncIN you should use a combination of functions FuncOR, FuncLike.

Переведено сервисом «Яндекс.Переводчик» http://translate.yandex.ru