Using the Terrasoft.Configuration.QueryExtensions utility class
The Terrasoft.Configuration.QueryExtensions utility class provides several extending methods for the Terrasoft.Core.DB.Select. This enables to build more compact queries.
As the object sourceColumn argument you can use following types (they will be transformed to the Terrasoft.Core.DB.QueryColumnExpression) for all extending methods:
- System.String – the name of the column in the TableAlias.ColumnName as ColumnAlias format (where the TableAlias and ColumnAlias are optional) or “*” – all columns.
- Terrasoft.Core.DB.QueryColumnExpression – will be added without changes.
- Terrasoft.Core.DB.IQueryColumnExpressionConvertible – will be converted.
- Terrasoft.Core.DB.Select – will be considered as subquery.
static Select Cols(this Select select, params object[] sourceColumns)
Adds specified columns or subexpressions to the query.
Using the Cols() extension method, instead of the following expression:
you can write:
static Select Count(this Select select, object sourceColumn)
Adds an aggregation column to calculate the number of non-empty values to the query.
For example, instead:
you can write:
static Select Coalesce(this Select select, params object[] sourceColumns)
Adds a column with the function of determining the first value not equal to NULL to the query.
For example, instead:
you can write:
static Select DateDiff(this Select select, DateDiffQueryFunctionInterval interval, object startDateExpression, object endDateExpression)
Adds a column that specifies the date difference to the query.
For example, instead:
you can write:
static Select IsNull(this Select select, object checkExpression, object replacementValue)
Adds a column with the function replacing NULL value with a replacement expression.
For example, instead:
you can write: