Class DataQuerySettingsBase<TQuery>
- Namespace
- CMS.DataEngine
- Assembly
- CMS.DataEngine.dll
Defines parameters for the data selection
public abstract class DataQuerySettingsBase<TQuery> : WhereConditionBase<TQuery>, IDataQuerySettings<TQuery>, IWhereCondition<TQuery>, IQueryParameters<TQuery>, IDataQuerySettings, IWhereCondition, IQueryParameters, IQueryObject where TQuery : DataQuerySettingsBase<TQuery>, new()
Type Parameters
TQuery
- Inheritance
-
objectQueryParametersBase<TQuery>WhereConditionBase<TQuery>DataQuerySettingsBase<TQuery>
- Implements
-
IDataQuerySettings<TQuery>IWhereCondition<TQuery>IQueryParameters<TQuery>
- Derived
- Inherited Members
- Extension Methods
Fields
mMaxRecords
Maximum number of records to select
protected int mMaxRecords
Field Value
- int
mOffset
Offset
protected int mOffset
Field Value
- int
mOrderByColumns
Order by columns
protected string mOrderByColumns
Field Value
- string
mSelectColumnsList
Columns to select
protected QueryColumnList mSelectColumnsList
Field Value
Properties
DefaultQuerySource
Default source of the query in case source is not defined
public virtual QuerySource DefaultQuerySource { get; set; }
Property Value
FilterColumns
List of columns used for extra filtering within the query, e.g. "CMS_C, CMS_RN"
public virtual QueryColumnList FilterColumns { get; set; }
Property Value
GetTotalRecordsForPagedQuery
If true, the query is configured to get total number of records when the paging is set. false
by default.
public virtual bool GetTotalRecordsForPagedQuery { get; set; }
Property Value
- bool
- See Also
GroupByColumns
List of columns to group by, by default doesn't group, e.g. "NodeLevel, NodeOwner"
public virtual string GroupByColumns { get; set; }
Property Value
- string
HasGroupBy
Returns true if the given query has group by set
public virtual bool HasGroupBy { get; }
Property Value
- bool
HavingCondition
Where condition for the group by on the data, e.g. "DocumentName = 'ABC'"
public virtual string HavingCondition { get; set; }
Property Value
- string
HavingIsComplex
Returns true if the given having condition is a complex condition
[Obsolete("Property was not intended for public use and will be removed in the next version.")]
[ObsoleteSince(27, 0)]
public bool HavingIsComplex { get; set; }
Property Value
- bool
HavingIsEmpty
Returns true if the having condition is empty
[Obsolete("Property was not intended for public use and will be removed in the next version.")]
[ObsoleteSince(27, 0)]
public bool HavingIsEmpty { get; }
Property Value
- bool
IsNested
Indicates that this query is nested within another query as its source. This brings certain constraints such as that is cannot use CTE.
public virtual bool IsNested { get; set; }
Property Value
- bool
IsPagedQuery
Returns true if the query has the paging enabled
public virtual bool IsPagedQuery { get; }
Property Value
- bool
IsSubQuery
If true, the query is a sub-query used in another query. This brings certain constraints such as that it cannot use order by or CTE.
public virtual bool IsSubQuery { get; set; }
Property Value
- bool
MaxRecords
Maximum number of results to return.
public virtual int MaxRecords { get; set; }
Property Value
- int
Remarks
Use for paging together with Offset. As query paging it cannot be combined with TopN(int) in the same query expression (in the same query scope) and requires order by to be configured.
Offset
Index of the first record to return.
public virtual int Offset { get; set; }
Property Value
- int
Remarks
Use for paging together with MaxRecords. As query paging it cannot be combined with TopN(int) in the same query expression (in the same query scope) and requires order by to be configured.
OrderByColumns
List of columns by which the result should be sorted, e.g. "NodeLevel, DocumentName DESC"
public virtual string OrderByColumns { get; set; }
Property Value
- string
QuerySource
Query source object
public virtual QuerySource QuerySource { get; set; }
Property Value
SelectColumnsList
List of columns to return, by default returns all columns, e.g. "DocumentName, DocumentID"
public virtual QueryColumnList SelectColumnsList { get; set; }
Property Value
SelectDistinct
If set to true, returns only distinct (different) values.
public virtual bool SelectDistinct { get; set; }
Property Value
- bool
TopNRecords
If set, selects only first top N number of records.
public virtual int TopNRecords { get; set; }
Property Value
- int
Remarks
Cannot be combined with Offset and MaxRecords in the same query expression (in the same query scope). Use Offset and MaxRecords instead to implement a query paging solution.
TotalExpression
Total items expression. When defined, used instead default total items for a paged query.
public virtual string TotalExpression { get; set; }
Property Value
- string
Methods
AddColumn(IQueryColumn)
Adds the additional column to the query
public virtual TQuery AddColumn(IQueryColumn column)
Parameters
column
IQueryColumnColumn to add
Returns
- TQuery
AddColumn(string)
Adds the additional column to the query
public virtual TQuery AddColumn(string column)
Parameters
column
stringColumn to add
Returns
- TQuery
AddColumns(params IQueryColumn[])
Adds the additional columns to the query
public virtual TQuery AddColumns(params IQueryColumn[] columns)
Parameters
columns
IQueryColumn[]Columns to add
Returns
- TQuery
AddColumns(IEnumerable<string>)
Adds the additional columns to the query
public virtual TQuery AddColumns(IEnumerable<string> columns)
Parameters
columns
IEnumerable<string>Columns to add
Returns
- TQuery
AddColumns(params string[])
Adds the additional columns to the query
public virtual TQuery AddColumns(params string[] columns)
Parameters
columns
string[]Columns to add
Returns
- TQuery
AddFilterColumn(IQueryColumn)
Adds the additional filter column to the query
public TQuery AddFilterColumn(IQueryColumn col)
Parameters
col
IQueryColumnColumn to add
Returns
- TQuery
AddHavingInternal(IWhereCondition)
Adds the given having condition
protected void AddHavingInternal(IWhereCondition condition)
Parameters
condition
IWhereConditionCondition to add
AnySettingsDefined()
Returns true if the object has any settings defined that influence the resulting query
protected override bool AnySettingsDefined()
Returns
- bool
ApplyParametersTo(IQueryObject)
Applies this query parameters to the target object
public override void ApplyParametersTo(IQueryObject target)
Parameters
target
IQueryObjectTarget object defining parameters
Column(IQueryColumn)
Sets the column to select
public virtual TQuery Column(IQueryColumn column)
Parameters
column
IQueryColumnColumn to set to be selected
Returns
- TQuery
Column(string)
Sets the column to select
public virtual TQuery Column(string column)
Parameters
column
stringColumn to set to be selected
Returns
- TQuery
Columns(params IQueryColumn[])
Sets the columns to select
public virtual TQuery Columns(params IQueryColumn[] columns)
Parameters
columns
IQueryColumn[]Columns to set to be selected
Returns
- TQuery
Columns(IEnumerable<string>)
Sets the columns to select
public virtual TQuery Columns(IEnumerable<string> columns)
Parameters
columns
IEnumerable<string>Columns to set to be selected
Returns
- TQuery
Columns(params string[])
Sets the columns to select
public virtual TQuery Columns(params string[] columns)
Parameters
columns
string[]Columns to set to be selected
Returns
- TQuery
CopyPropertiesTo(IQueryObject)
Creates the clone of the collection.
public override void CopyPropertiesTo(IQueryObject target)
Parameters
target
IQueryObjectTarget class
Distinct(bool)
Sets the query to use distinct selection over the given columns
public virtual TQuery Distinct(bool distinct = true)
Parameters
distinct
boolIf set to true, returns only distinct (different) values.
Returns
- TQuery
GetDefaultSource()
Gets the default source for this query
protected virtual QuerySource GetDefaultSource()
Returns
GetExpressions(QueryDataParameters)
Gets the query expressions
public QueryMacros GetExpressions(QueryDataParameters parameters)
Parameters
parameters
QueryDataParametersQuery data parameters
Returns
GroupBy(params string[])
Specifies the columns to group by
public virtual TQuery GroupBy(params string[] columns)
Parameters
columns
string[]List of columns to group by
Returns
- TQuery
Having(params IWhereCondition[])
Adds the given having conditions to the query.
public virtual TQuery Having(params IWhereCondition[] conditions)
Parameters
conditions
IWhereCondition[]Having where conditions
Returns
- TQuery
Having(Action<WhereCondition>)
Adds the given where condition to the query. Creates a new where condition object and runs the setup actions on it.
public virtual TQuery Having(Action<WhereCondition> condition)
Parameters
condition
Action<WhereCondition>Nested where condition
Returns
- TQuery
Having(string, bool)
Specifies the having condition
public virtual TQuery Having(string having, bool replace = false)
Parameters
having
stringHaving condition
replace
boolIf true, the having condition replaces the original having condition
Returns
- TQuery
NewGroupBy(params string[])
Clears the current group by, reverting the source of data to the original. Note, that this method also resets the existing having condition which is closely bound to the group by.
[Obsolete("Method was not intended for public use and will be removed in the next version.")]
[ObsoleteSince(27, 0)]
public virtual TQuery NewGroupBy(params string[] columns)
Parameters
columns
string[]
Returns
- TQuery
NewHaving()
Clears the current having condition
[Obsolete("Method was not intended for public use and will be removed in the next version.")]
[ObsoleteSince(27, 0)]
public virtual TQuery NewHaving()
Returns
- TQuery
NextPage()
Adjusts the query to a next page, using the current page size. Use in combination with PagedBy and NextPageAvailable to iterate over the data in batches.
public virtual TQuery NextPage()
Returns
- TQuery
Remarks
Number of records in one page can be specified by setting MaxRecords property or calling PagedBy() method.
NoColumns()
Sets the query to return no columns at all
protected TQuery NoColumns()
Returns
- TQuery
NotPaged()
Sets up the query to become not paged query and output all results at once.
[Obsolete("Method was not intended for public use and will be removed in the next version.")]
[ObsoleteSince(27, 0)]
public virtual TQuery NotPaged()
Returns
- TQuery
OrderBy(OrderDirection, params string[])
Adds the columns to the order by query
public virtual TQuery OrderBy(OrderDirection dir, params string[] columns)
Parameters
dir
OrderDirectionOrder direction
columns
string[]Columns to add to order by
Returns
- TQuery
OrderBy(params string[])
Adds the columns to the order by query
public virtual TQuery OrderBy(params string[] columns)
Parameters
columns
string[]Columns to add to order by
Returns
- TQuery
OrderByAscending(params string[])
Adds the columns to the order by query to order by the given columns in ascending order
public virtual TQuery OrderByAscending(params string[] columns)
Parameters
columns
string[]Columns to add to order by
Returns
- TQuery
OrderByDescending(params string[])
Adds the columns to the order by query to order by the given columns in descending order
public virtual TQuery OrderByDescending(params string[] columns)
Parameters
columns
string[]Columns to add to order by
Returns
- TQuery
Page(int, int)
Specifies the page to select with given page index and page size. Page number is indexed from 0 (first page).
public virtual TQuery Page(int pageIndex, int pageSize)
Parameters
pageIndex
intpageSize
int
Returns
- TQuery
Remarks
Cannot be combined with TopN(int) in the same query expression (in the same query scope) and requires order by to be configured.
PagedBy(int)
Sets up the query as a paged query with the given page size. Resets the page index to first page. Use in combination with NextPageAvailable and NextPage to iterate over the data in batches.
public virtual TQuery PagedBy(int pageSize)
Parameters
pageSize
int
Returns
- TQuery
Remarks
Note that if you iterate the results after calling this method, the results will cover only a single page. To iterate through all items page-by-page, use methods ForEachRow or ForEachObject. Cannot be combined with TopN(int) in the same query expression (in the same query scope) and requires order by to be configured.
ReplaceColumn(string, string)
Replaces the selected column with a new name
public virtual TQuery ReplaceColumn(string originalName, string newName)
Parameters
originalName
stringOriginal column name
newName
stringNew column name
Returns
- TQuery
ReplaceOrderByColumn(string, string)
Replaces the selected column with a new name
protected void ReplaceOrderByColumn(string originalName, string newName)
Parameters
originalName
stringOriginal column name
newName
stringNew column name
ReplaceSelectedColumn(string, string)
Replaces the selected column with a new name
protected void ReplaceSelectedColumn(string originalName, string newName)
Parameters
originalName
stringOriginal column name
newName
stringNew column name
Take()
Identity method to make the query expression more readable. Use before the Columns or Page method. Doesn't provide any functionality.
public virtual TQuery Take()
Returns
- TQuery
Then()
Identity method to make the query expression more readable. Use before the OrderBy method. Doesn't provide any functionality.
public virtual TQuery Then()
Returns
- TQuery
ToString(bool)
Returns the string representation of the expression, with possibility of expanding parameters
public override string ToString(bool expand)
Parameters
expand
boolIf true, the result is expanded with parameters so it can act as standalone value.
Returns
- string
TopN(int)
Selects only first top N number of records.
public virtual TQuery TopN(int topN)
Parameters
topN
int
Returns
- TQuery
Remarks
Cannot be combined with Offset and MaxRecords in the same query expression (in the same query scope). Use Offset and MaxRecords instead to implement a query paging solution.