MacroExpression

Overview

Instances of the MacroExpression class can be used to represent direct calls to the SQL function of the underlying database server.

For example: this SQL expression

DATEADD(DAY, 1, CURRENT_TIMESTAMP)

can be represented as

new MacroExpression("DATEADD",
  new WhereExpression[] { 
    new MacroExpression("DAY"), 
    new ConstantExpression(1), 
    new MacroExpression("CURRENT_TIMESTAMP") });

Please note that a WhereExpression containing a MacroExpression cannot be used to perform Dynamic Where clauses due to security restrictions (allowing it would enable SQL injection attacks via Dynamic Where).

Instead, you can provide a custom DataService method that accepts the WhereExpression parameter and converts it into SQL using the ToSqlString method.

Location

 

constructor

Creates a new instance of the MacroExpression class.

 

constructor

 

MacroExpression()

 

Sub New

constructor (String)

Creates a new instance of the MacroExpression class and initializes its Name property.

 

constructor(name: String)

 

MacroExpression(String name)

 

Sub New (name As String)

Parameters:

  • name:

constructor (String, array of WhereExpression)

 

constructor(name: String; params values: array of WhereExpression)

 

MacroExpression(String name, params WhereExpression[] values)

 

Sub New (name As String, ParamArray values As array of WhereExpression)

Parameters:

  • name:
  • values:

Add

Adds a provided WhereExpression instance to the list of macro parameter values.

 

method Add(value: WhereExpression)

 

void Add(WhereExpression value)

 

Sub Add(value As WhereExpression)

Parameters:

  • value: The macro parameter to be added.

ApplyFieldMapping

 

method ApplyFieldMapping(mappings: SchemaColumnMappingCollection)

 

void ApplyFieldMapping(SchemaColumnMappingCollection mappings)

 

Sub ApplyFieldMapping(mappings As SchemaColumnMappingCollection)

Parameters:

  • mappings:

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:

 

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:

Count

Gets a count of defined macro parameters.

 

property Count: Int32 read;

 

Int32 Count { get; }

 

Property ReadOnly Count As Int32

ExtractAllConstantExpression

 

method ExtractAllConstantExpression(expressions: List<ConstantExpression>)

 

void ExtractAllConstantExpression(List<ConstantExpression> expressions)

 

Sub ExtractAllConstantExpression(expressions As List<ConstantExpression>)

Parameters:

  • expressions:

ExtractAllFieldNames

 

method ExtractAllFieldNames(fields: List<String>)

 

void ExtractAllFieldNames(List<String> fields)

 

Sub ExtractAllFieldNames(fields As List<String>)

Parameters:

  • fields:

ExtractAllParams

 

method ExtractAllParams(parameters: SchemaParameterCollection)

 

void ExtractAllParams(SchemaParameterCollection parameters)

 

Sub ExtractAllParams(parameters As SchemaParameterCollection)

Parameters:

  • parameters:

FromString    (declared in WhereExpression)

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    (declared in WhereExpression)

 

class method FromStringToSql(xml: String): String

 

static String FromStringToSql(String xml)

 

Shared Function FromStringToSql(xml As String) As String

Parameters:

  • xml:

FromXmlNode    (declared in WhereExpression)

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:

Insert

 

method Insert(index: Int32; value: WhereExpression)

 

void Insert(Int32 index, WhereExpression value)

 

Sub Insert(index As Int32, value As WhereExpression)

Parameters:

  • index:
  • value:

Item

Gets or sets a macro parameter at the idx position.

 

property Item[index: Int32]: WhereExpression read write;

 

WhereExpression Item[Int32 index] { get; set; }

 

Property Item(index As Int32) As WhereExpression

Kind

Gets the kind of the current WhereExpression instance. For the MacroExpression class, this property always equals WhereKind.Macro.

 

property Kind: WhereKind read;

 

WhereKind Kind { get; }

 

Property ReadOnly Kind As WhereKind

Name

Name of the macro expression. Can be considered as name of the underlying SQL function.

 

property Name: String read write;

 

String Name { get; set; }

 

Property Name As String

ParseExpression    (declared in WhereExpression)

 

class method ParseExpression(node: XmlNode): WhereExpression

 

static WhereExpression ParseExpression(XmlNode node)

 

Shared Function ParseExpression(node As XmlNode) As WhereExpression

Parameters:

  • node:

ReadFromXml

Deserializes the MacroExpression from the provided XmlNode.

 

method ReadFromXml(node: XmlNode)

 

void ReadFromXml(XmlNode node)

 

Sub ReadFromXml(node As XmlNode)

Parameters:

  • node:

Remove

 

method Remove(value: WhereExpression)

 

void Remove(WhereExpression value)

 

Sub Remove(value As WhereExpression)

Parameters:

  • value:

RemoveAt

Removes the macro parameter stored in the macro parameters list at the index position.

 

method RemoveAt(index: Int32)

 

void RemoveAt(Int32 index)

 

Sub RemoveAt(index As Int32)

Parameters:

  • index:

ToSQLString    (declared in WhereExpression)

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)

Converts the current MacroExpression instance to its SQL representation and adds the result of this conversion to the provided StringBuilder.

 

method ToSQLString(destination: StringBuilder)

 

void ToSQLString(StringBuilder destination)

 

Sub ToSQLString(destination As StringBuilder)

Parameters:

  • destination:

ToString    (declared in WhereExpression)

Returns a SQL string representation of the current expression.

 

method ToString: String

 

String ToString()

 

Function ToString As String

ToXmlNode    (declared in WhereExpression)

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

 

method ToXmlNode: XmlNode

 

XmlNode ToXmlNode()

 

Function ToXmlNode As XmlNode

ToXmlString    (declared in WhereExpression)

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    (declared in WhereExpression)

 

method Validate: Boolean

 

Boolean Validate()

 

Function Validate As Boolean

Validate (WhereExpression): Boolean    (declared in WhereExpression)

 

class method Validate(expression: WhereExpression): Boolean

 

static Boolean Validate(WhereExpression expression)

 

Shared Function Validate(expression As WhereExpression) As Boolean

Parameters:

  • expression:

WriteToXml

Serializes the current MacroExpression instance to XML and stores the serialization result in the provided XmlNode.

 

method WriteToXml(node: XmlNode)

 

void WriteToXml(XmlNode node)

 

Sub WriteToXml(node As XmlNode)

Parameters:

  • node:

 

Count

Gets a count of defined macro parameters.

 

property Count: Int32 read;

 

Int32 Count { get; }

 

Property ReadOnly Count As Int32

Item

Gets or sets a macro parameter at the idx position.

 

property Item[index: Int32]: WhereExpression read write;

 

WhereExpression Item[Int32 index] { get; set; }

 

Property Item(index As Int32) As WhereExpression

Kind

Gets the kind of the current WhereExpression instance. For the MacroExpression class, this property always equals WhereKind.Macro.

 

property Kind: WhereKind read;

 

WhereKind Kind { get; }

 

Property ReadOnly Kind As WhereKind

Name

Name of the macro expression. Can be considered as name of the underlying SQL function.

 

property Name: String read write;

 

String Name { get; set; }

 

Property Name As String

 

 

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    (declared in WhereExpression)

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    (declared in WhereExpression)

 

class method FromStringToSql(xml: String): String

 

static String FromStringToSql(String xml)

 

Shared Function FromStringToSql(xml As String) As String

Parameters:

  • xml:

FromXmlNode    (declared in WhereExpression)

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    (declared in WhereExpression)

 

class method ParseExpression(node: XmlNode): WhereExpression

 

static WhereExpression ParseExpression(XmlNode node)

 

Shared Function ParseExpression(node As XmlNode) As WhereExpression

Parameters:

  • node:

Validate (WhereExpression): Boolean    (declared in WhereExpression)

 

class method Validate(expression: WhereExpression): Boolean

 

static Boolean Validate(WhereExpression expression)

 

Shared Function Validate(expression As WhereExpression) As Boolean

Parameters:

  • expression:

 

constructor

Creates a new instance of the MacroExpression class.

 

constructor

 

MacroExpression()

 

Sub New

constructor (String)

Creates a new instance of the MacroExpression class and initializes its Name property.

 

constructor(name: String)

 

MacroExpression(String name)

 

Sub New (name As String)

Parameters:

  • name:

constructor (String, array of WhereExpression)

 

constructor(name: String; params values: array of WhereExpression)

 

MacroExpression(String name, params WhereExpression[] values)

 

Sub New (name As String, ParamArray values As array of WhereExpression)

Parameters:

  • name:
  • values:

Add

Adds a provided WhereExpression instance to the list of macro parameter values.

 

method Add(value: WhereExpression)

 

void Add(WhereExpression value)

 

Sub Add(value As WhereExpression)

Parameters:

  • value: The macro parameter to be added.

ApplyFieldMapping

 

method ApplyFieldMapping(mappings: SchemaColumnMappingCollection)

 

void ApplyFieldMapping(SchemaColumnMappingCollection mappings)

 

Sub ApplyFieldMapping(mappings As SchemaColumnMappingCollection)

Parameters:

  • mappings:

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

 

method ExtractAllConstantExpression(expressions: List<ConstantExpression>)

 

void ExtractAllConstantExpression(List<ConstantExpression> expressions)

 

Sub ExtractAllConstantExpression(expressions As List<ConstantExpression>)

Parameters:

  • expressions:

ExtractAllFieldNames

 

method ExtractAllFieldNames(fields: List<String>)

 

void ExtractAllFieldNames(List<String> fields)

 

Sub ExtractAllFieldNames(fields As List<String>)

Parameters:

  • fields:

ExtractAllParams

 

method ExtractAllParams(parameters: SchemaParameterCollection)

 

void ExtractAllParams(SchemaParameterCollection parameters)

 

Sub ExtractAllParams(parameters As SchemaParameterCollection)

Parameters:

  • parameters:

Insert

 

method Insert(index: Int32; value: WhereExpression)

 

void Insert(Int32 index, WhereExpression value)

 

Sub Insert(index As Int32, value As WhereExpression)

Parameters:

  • index:
  • value:

ReadFromXml

Deserializes the MacroExpression from the provided XmlNode.

 

method ReadFromXml(node: XmlNode)

 

void ReadFromXml(XmlNode node)

 

Sub ReadFromXml(node As XmlNode)

Parameters:

  • node:

Remove

 

method Remove(value: WhereExpression)

 

void Remove(WhereExpression value)

 

Sub Remove(value As WhereExpression)

Parameters:

  • value:

RemoveAt

Removes the macro parameter stored in the macro parameters list at the index position.

 

method RemoveAt(index: Int32)

 

void RemoveAt(Int32 index)

 

Sub RemoveAt(index As Int32)

Parameters:

  • index:

ToSQLString    (declared in WhereExpression)

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)

Converts the current MacroExpression instance to its SQL representation and adds the result of this conversion to the provided StringBuilder.

 

method ToSQLString(destination: StringBuilder)

 

void ToSQLString(StringBuilder destination)

 

Sub ToSQLString(destination As StringBuilder)

Parameters:

  • destination:

ToString    (declared in WhereExpression)

Returns a SQL string representation of the current expression.

 

method ToString: String

 

String ToString()

 

Function ToString As String

ToXmlNode    (declared in WhereExpression)

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

 

method ToXmlNode: XmlNode

 

XmlNode ToXmlNode()

 

Function ToXmlNode As XmlNode

ToXmlString    (declared in WhereExpression)

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    (declared in WhereExpression)

 

method Validate: Boolean

 

Boolean Validate()

 

Function Validate As Boolean

WriteToXml

Serializes the current MacroExpression instance to XML and stores the serialization result in the provided XmlNode.

 

method WriteToXml(node: XmlNode)

 

void WriteToXml(XmlNode node)

 

Sub WriteToXml(node As XmlNode)

Parameters:

  • node: