WhereExpression

Overview

The base abstract class for classes that represent WHERE expression tree nodes:

  • BinaryExpression combines two other expressions with a binary operator (such as equality or binary logical operators);
  • UnaryExpression represents expressions, based in the application of a unary operator (like the change of sign or logical negation) to another, inner expression;
  • BetweenExpression represents expression that checks belonging to a range of values;
  • ConstantExpression - the constant values that appear in an expression are represented through objects of this class;
  • ListExpression is a complex expression, represented by a list of expressions;
  • ParameterExpression - the parameters (variables) of an expression are represented through objects of this class;
  • FieldExpression represents the part of expression containing table field names;
  • NullExpression represents NULL values used in the expression;
  • MacroExpression represents a call to a macro function, which will be processed by Macro Processor.

This class is used to dynamically build WHERE statements from code (Dynamic Where feature of Data Abstract).

For example, a WHERE part of this query

SELECT * FROM Employees WHERE ((Position = 'Sales Manager') 
OR (Zip IS NULL)) AND (City IN ('Atlanta GA', 'Seattle WA', 'New York CA'))

will be presented as:

WhereExpression lResult;
lResult = new BinaryExpression(new BinaryExpression(
            new BinaryExpression(
              new FieldExpression("Position"),
              new ConstantExpression("Sales Manager", DataType.String),BinaryOperator.Equal),
              new BinaryExpression(
              new FieldExpression("Zip"),
              new NullExpression(),BinaryOperator.Equal),BinaryOperator.Or),

              new BinaryExpression(
                new FieldExpression("City"),
                new ListExpression(
                new WhereExpression[]{ new ConstantExpression("Atlanta GA",DataType.String),
                                   new ConstantExpression("Seattle WA", DataType.String),
                                   new ConstantExpression("New York CA", DataType.String) }),
             BinaryOperator.In),

           BinaryOperator.And);

Location


 

constructor  protected

 

constructor

 

WhereExpression()

 

Sub New()

ApplyFieldMapping

Adjusts the field names in the WhereExpression in accordance with table names of fields in the given schema column mapping.

 

method ApplyFieldMapping(columnMappings: SchemaColumnMappingCollection)

 

void ApplyFieldMapping(SchemaColumnMappingCollection columnMappings)

 

Sub ApplyFieldMapping(columnMappings As SchemaColumnMappingCollection)

Parameters:

  • columnMappings:

ApplySourceTableNumber

 

method ApplySourceTableNumber(number: Int32): WhereExpression

 

WhereExpression ApplySourceTableNumber(Int32 number)

 

Function ApplySourceTableNumber(number As Int32) As WhereExpression

Parameters:

  • number:

ApplyTableMapping

 

method ApplyTableMapping(schemaTable: String; databaseTable: String)

 

void ApplyTableMapping(String schemaTable, String databaseTable)

 

Sub ApplyTableMapping(schemaTable As String, databaseTable As String)

Parameters:

  • schemaTable:
  • databaseTable:

ApplyTableNameOrAlias

 

method ApplyTableNameOrAlias(name: String)

 

void ApplyTableNameOrAlias(String name)

 

Sub ApplyTableNameOrAlias(name As String)

Parameters:

  • name:

Creates new BinaryExpression from given aLeft and aRight operands, using operator And.

 

class method Combine(left: WhereExpression; right: WhereExpression): WhereExpression

 

static WhereExpression Combine(WhereExpression left, WhereExpression right)

 

Shared Function Combine(left As WhereExpression, right As WhereExpression) As WhereExpression

Parameters:

  • left:
  • right:

 

class method Combine(left: WhereExpression; right: WhereExpression; operator: BinaryOperator): WhereExpression

 

static WhereExpression Combine(WhereExpression left, WhereExpression right, BinaryOperator operator)

 

Shared Function Combine(left As WhereExpression, right As WhereExpression, operator As BinaryOperator) As WhereExpression

Parameters:

  • left:
  • right:
  • operator:

ExtractAllConstantExpression

Establishes a list of all ConstantExpression contained in the WhereExpression.

 

method ExtractAllConstantExpression(expressions: List<ConstantExpression>)

 

void ExtractAllConstantExpression(List<ConstantExpression> expressions)

 

Sub ExtractAllConstantExpression(expressions As List<ConstantExpression>)

Parameters:

  • expressions:

ExtractAllFieldNames

Establishes a list of field names used in the WhereExpression.

 

method ExtractAllFieldNames(fieldNames: List<String>)

 

void ExtractAllFieldNames(List<String> fieldNames)

 

Sub ExtractAllFieldNames(fieldNames As List<String>)

Parameters:

  • fieldNames:

ExtractAllParams

Fills SchemaParameterCollection with ParameterExpressions and ConstantExpressions (as ParameterExpressions) contained in the WhereExpression.

 

method ExtractAllParams(parameters: SchemaParameterCollection)

 

void ExtractAllParams(SchemaParameterCollection parameters)

 

Sub ExtractAllParams(parameters As SchemaParameterCollection)

Parameters:

  • parameters:

FromString

Creates new WhereExpression from string, which should contain where node in the correct Dynamic Where XML Format.

 

class method FromString(xml: String): WhereExpression

 

static WhereExpression FromString(String xml)

 

Shared Function FromString(xml As String) As WhereExpression

Parameters:

  • xml:

FromStringToSql

 

class method FromStringToSql(xml: String): String

 

static String FromStringToSql(String xml)

 

Shared Function FromStringToSql(xml As String) As String

Parameters:

  • xml:

FromXmlNode

Creates new WhereExpression from xml node, which should be in the correct Dynamic Where XML Format.

 

class method FromXmlNode(node: XmlNode): WhereExpression

 

static WhereExpression FromXmlNode(XmlNode node)

 

Shared Function FromXmlNode(node As XmlNode) As WhereExpression

Parameters:

  • node:

Kind

Abstract readonly property, which represents the type of WHERE expression in the descendant class.

 

property Kind: WhereKind read;

 

WhereKind Kind { get; }

 

ReadOnly Property Kind() As WhereKind

ParseExpression

 

class method ParseExpression(node: XmlNode): WhereExpression

 

static WhereExpression ParseExpression(XmlNode node)

 

Shared Function ParseExpression(node As XmlNode) As WhereExpression

Parameters:

  • node:

ReadFromXml

Abstract method. In descendants creates WhereExpression from the given xml node, that should be in the correct Dynamic Where XML Format.

 

method ReadFromXml(node: XmlNode)

 

void ReadFromXml(XmlNode node)

 

Sub ReadFromXml(node As XmlNode)

Parameters:

  • node:

ToSQLString

A helper method that wraps the similar one with the string builder and returns a SQL string.

 

method ToSQLString: String

 

String ToSQLString()

 

Function ToSQLString() As String

ToSQLString (StringBuilder)

Creates an SQL representation of thу current where expression instance and appends it to the provided StringBuilder.

 

method ToSQLString(destination: StringBuilder)

 

void ToSQLString(StringBuilder destination)

 

Sub ToSQLString(destination As StringBuilder)

Parameters:

  • destination: The destination string builder to be appended.

ToString

Returns a SQL string representation of the current expression.

 

method ToString: String

 

String ToString()

 

Function ToString() As String

ToXmlNode

Creates query node (in the Dynamic Where XML Format) from WhereExpression.

 

method ToXmlNode: XmlNode

 

XmlNode ToXmlNode()

 

Function ToXmlNode() As XmlNode

ToXmlString

Creates query node (in the Dynamic Where XML Format) from WhereExpression and returns it in the string format.

 

method ToXmlString: String

 

String ToXmlString()

 

Function ToXmlString() As String

Validate

 

method Validate: Boolean

 

Boolean Validate()

 

Function Validate() As Boolean

Validate (WhereExpression): Boolean

Validates that WhereExpression doesn't contain any errors, using WhereValidator. The main purpose of this validation - to scan all objects of WhereExpession tree and make sure that it contains correct field names.

 

class method Validate(expression: WhereExpression): Boolean

 

static Boolean Validate(WhereExpression expression)

 

Shared Function Validate(expression As WhereExpression) As Boolean

Parameters:

  • expression:

WriteToXml

Abstract method. In descendants creates where node (in the Dynamic Where XML Format) from WhereExpression.

 

method WriteToXml(node: XmlNode)

 

void WriteToXml(XmlNode node)

 

Sub WriteToXml(node As XmlNode)

Parameters:

  • node:

 

Kind

Abstract readonly property, which represents the type of WHERE expression in the descendant class.

 

property Kind: WhereKind read;

 

WhereKind Kind { get; }

 

ReadOnly Property Kind() As WhereKind

 

Creates new BinaryExpression from given aLeft and aRight operands, using operator And.

 

class method Combine(left: WhereExpression; right: WhereExpression): WhereExpression

 

static WhereExpression Combine(WhereExpression left, WhereExpression right)

 

Shared Function Combine(left As WhereExpression, right As WhereExpression) As WhereExpression

Parameters:

  • left:
  • right:

 

class method Combine(left: WhereExpression; right: WhereExpression; operator: BinaryOperator): WhereExpression

 

static WhereExpression Combine(WhereExpression left, WhereExpression right, BinaryOperator operator)

 

Shared Function Combine(left As WhereExpression, right As WhereExpression, operator As BinaryOperator) As WhereExpression

Parameters:

  • left:
  • right:
  • operator:

FromString

Creates new WhereExpression from string, which should contain where node in the correct Dynamic Where XML Format.

 

class method FromString(xml: String): WhereExpression

 

static WhereExpression FromString(String xml)

 

Shared Function FromString(xml As String) As WhereExpression

Parameters:

  • xml:

FromStringToSql

 

class method FromStringToSql(xml: String): String

 

static String FromStringToSql(String xml)

 

Shared Function FromStringToSql(xml As String) As String

Parameters:

  • xml:

FromXmlNode

Creates new WhereExpression from xml node, which should be in the correct Dynamic Where XML Format.

 

class method FromXmlNode(node: XmlNode): WhereExpression

 

static WhereExpression FromXmlNode(XmlNode node)

 

Shared Function FromXmlNode(node As XmlNode) As WhereExpression

Parameters:

  • node:

ParseExpression

 

class method ParseExpression(node: XmlNode): WhereExpression

 

static WhereExpression ParseExpression(XmlNode node)

 

Shared Function ParseExpression(node As XmlNode) As WhereExpression

Parameters:

  • node:

Validate (WhereExpression): Boolean

Validates that WhereExpression doesn't contain any errors, using WhereValidator. The main purpose of this validation - to scan all objects of WhereExpession tree and make sure that it contains correct field names.

 

class method Validate(expression: WhereExpression): Boolean

 

static Boolean Validate(WhereExpression expression)

 

Shared Function Validate(expression As WhereExpression) As Boolean

Parameters:

  • expression:

 

constructor  protected

 

constructor

 

WhereExpression()

 

Sub New()

ApplyFieldMapping

Adjusts the field names in the WhereExpression in accordance with table names of fields in the given schema column mapping.

 

method ApplyFieldMapping(columnMappings: SchemaColumnMappingCollection)

 

void ApplyFieldMapping(SchemaColumnMappingCollection columnMappings)

 

Sub ApplyFieldMapping(columnMappings As SchemaColumnMappingCollection)

Parameters:

  • columnMappings:

ApplySourceTableNumber

 

method ApplySourceTableNumber(number: Int32): WhereExpression

 

WhereExpression ApplySourceTableNumber(Int32 number)

 

Function ApplySourceTableNumber(number As Int32) As WhereExpression

Parameters:

  • number:

ApplyTableMapping

 

method ApplyTableMapping(schemaTable: String; databaseTable: String)

 

void ApplyTableMapping(String schemaTable, String databaseTable)

 

Sub ApplyTableMapping(schemaTable As String, databaseTable As String)

Parameters:

  • schemaTable:
  • databaseTable:

ApplyTableNameOrAlias

 

method ApplyTableNameOrAlias(name: String)

 

void ApplyTableNameOrAlias(String name)

 

Sub ApplyTableNameOrAlias(name As String)

Parameters:

  • name:

ExtractAllConstantExpression

Establishes a list of all ConstantExpression contained in the WhereExpression.

 

method ExtractAllConstantExpression(expressions: List<ConstantExpression>)

 

void ExtractAllConstantExpression(List<ConstantExpression> expressions)

 

Sub ExtractAllConstantExpression(expressions As List<ConstantExpression>)

Parameters:

  • expressions:

ExtractAllFieldNames

Establishes a list of field names used in the WhereExpression.

 

method ExtractAllFieldNames(fieldNames: List<String>)

 

void ExtractAllFieldNames(List<String> fieldNames)

 

Sub ExtractAllFieldNames(fieldNames As List<String>)

Parameters:

  • fieldNames:

ExtractAllParams

Fills SchemaParameterCollection with ParameterExpressions and ConstantExpressions (as ParameterExpressions) contained in the WhereExpression.

 

method ExtractAllParams(parameters: SchemaParameterCollection)

 

void ExtractAllParams(SchemaParameterCollection parameters)

 

Sub ExtractAllParams(parameters As SchemaParameterCollection)

Parameters:

  • parameters:

ReadFromXml

Abstract method. In descendants creates WhereExpression from the given xml node, that should be in the correct Dynamic Where XML Format.

 

method ReadFromXml(node: XmlNode)

 

void ReadFromXml(XmlNode node)

 

Sub ReadFromXml(node As XmlNode)

Parameters:

  • node:

ToSQLString

A helper method that wraps the similar one with the string builder and returns a SQL string.

 

method ToSQLString: String

 

String ToSQLString()

 

Function ToSQLString() As String

ToSQLString (StringBuilder)

Creates an SQL representation of thу current where expression instance and appends it to the provided StringBuilder.

 

method ToSQLString(destination: StringBuilder)

 

void ToSQLString(StringBuilder destination)

 

Sub ToSQLString(destination As StringBuilder)

Parameters:

  • destination: The destination string builder to be appended.

ToString

Returns a SQL string representation of the current expression.

 

method ToString: String

 

String ToString()

 

Function ToString() As String

ToXmlNode

Creates query node (in the Dynamic Where XML Format) from WhereExpression.

 

method ToXmlNode: XmlNode

 

XmlNode ToXmlNode()

 

Function ToXmlNode() As XmlNode

ToXmlString

Creates query node (in the Dynamic Where XML Format) from WhereExpression and returns it in the string format.

 

method ToXmlString: String

 

String ToXmlString()

 

Function ToXmlString() As String

Validate

 

method Validate: Boolean

 

Boolean Validate()

 

Function Validate() As Boolean

WriteToXml

Abstract method. In descendants creates where node (in the Dynamic Where XML Format) from WhereExpression.

 

method WriteToXml(node: XmlNode)

 

void WriteToXml(XmlNode node)

 

Sub WriteToXml(node As XmlNode)

Parameters:

  • node: