Class MultiQueryBase<TQuery, TInnerQuery>
- Namespace
 - CMS.DataEngine
 
- Assembly
 - CMS.DataEngine.dll
 
Base class for the query consisting of multiple queries
public abstract class MultiQueryBase<TQuery, TInnerQuery> : DataQueryBase<TQuery>, IMultiQuery<TQuery, TInnerQuery>, IDataQuery<TQuery>, IDataQuerySettings<TQuery>, IWhereCondition<TQuery>, IQueryParameters<TQuery>, IMultiQuery, IDataQuery, IDataQuerySettings, IWhereCondition, IQueryParameters, IQueryObjectWithValue, IQueryObject where TQuery : MultiQueryBase<TQuery, TInnerQuery>, new() where TInnerQuery : AbstractQueryObject, IDataQuery<TInnerQuery>, new()
  Type Parameters
TQueryTInnerQuery
- Inheritance
 - 
      objectQueryParametersBase<TQuery>WhereConditionBase<TQuery>DataQuerySettingsBase<TQuery>DataQueryBase<TQuery>MultiQueryBase<TQuery, TInnerQuery>
 
- Implements
 - 
      IMultiQuery<TQuery, TInnerQuery>IDataQuery<TQuery>IDataQuerySettings<TQuery>IWhereCondition<TQuery>IQueryParameters<TQuery>
 
- Derived
 
- Inherited Members
 
- Extension Methods
 
Constructors
MultiQueryBase()
Constructor
protected MultiQueryBase()
  Properties
DefaultOrderByType
If true, the result is ordered by source type by default, then by source order. If false (default), the result is ordered by the source order, and items from different types may interleave.
public bool DefaultOrderByType { get; set; }
  Property Value
- bool
 
DefaultQuery
Default query used by the process when type queries are not used.
protected TInnerQuery DefaultQuery { get; set; }
  Property Value
- TInnerQuery
 
OrderByResultColumns
List of columns for the result order by. If not specified, the result is ordered by sources and global order by.
public virtual string OrderByResultColumns { get; set; }
  Property Value
- string
 
Queries
Inner queries. Can be used to search for specific query.
public StringSafeDictionary<TInnerQuery> Queries { get; protected set; }
  Property Value
- StringSafeDictionary<TInnerQuery>
 
QueriesList
Inner queries list. Defines order of the queries.
public List<TInnerQuery> QueriesList { get; protected set; }
  Property Value
- List<TInnerQuery>
 
ReturnsSingleColumn
Returns true if the query returns single column
public override bool ReturnsSingleColumn { get; }
  Property Value
- bool
 
SelectResultColumnsList
List of columns to use for results, by default returns all columns defined in the inner queries. Example: "DocumentName, DocumentID"
public virtual QueryColumnList SelectResultColumnsList { get; set; }
  Property Value
SelectedTypes
Returns the types of the inner queries
public IEnumerable<string> SelectedTypes { get; }
  Property Value
- IEnumerable<string>
 
UseDefaultQuery
Flag indicating if the default query should be forcibly used. Default false. This flag is automatically reverted to false in case initializer of particular type query is used through Type("sometype", q => q.Where(...)).
protected UseDefaultQueryEnum UseDefaultQuery { get; set; }
  Property Value
UseGlobalWhereOnResult
If true, the global where condition from the parent query is used outside the inner queries on the whole result. If false (default), the global where condition is used inside individual inner queries.
[Obsolete("Property was not intended for public use and will be removed in the next version.")]
public bool UseGlobalWhereOnResult { get; set; }
  Property Value
- bool
 
UseOrderBy
Flag indicating whether the OrderBy parameter should be applied.
protected virtual bool UseOrderBy { get; }
  Property Value
- bool
 
UseTypeColumns
If true (default), the query uses type columns for the output, otherwise it uses only global columns
public virtual bool UseTypeColumns { get; set; }
  Property Value
- bool
 
Methods
AddResultColumn(IQueryColumn)
Adds the additional column to the query
public virtual TQuery AddResultColumn(IQueryColumn column)
  Parameters
columnIQueryColumnColumn to add
Returns
- TQuery
 
AddResultColumn(string)
Adds the additional column to the query
public virtual TQuery AddResultColumn(string column)
  Parameters
columnstringColumn to add
Returns
- TQuery
 
AddResultColumns(params IQueryColumn[])
Adds the additional columns to the query
public virtual TQuery AddResultColumns(params IQueryColumn[] columns)
  Parameters
columnsIQueryColumn[]Columns to add
Returns
- TQuery
 
AddResultColumns(IEnumerable<string>)
Adds the additional columns to the query
public virtual TQuery AddResultColumns(IEnumerable<string> columns)
  Parameters
columnsIEnumerable<string>Columns to add
Returns
- TQuery
 
AddResultColumns(params string[])
Adds the additional columns to the query
public virtual TQuery AddResultColumns(params string[] columns)
  Parameters
columnsstring[]Columns to add
Returns
- TQuery
 
ApplyGlobalParametersToOuterQuery(ref DataQuery, DataQuerySettings, bool)
Applies global parameters to a sub-queries outer query
protected virtual void ApplyGlobalParametersToOuterQuery(ref DataQuery query, DataQuerySettings globalSettings, bool isSingleQuery)
  Parameters
queryDataQueryOuter query
globalSettingsDataQuerySettingsGlobal parameters for the query
isSingleQueryboolIndicates if the query is a single query
ApplyGlobalParametersToSubqueries(List<TInnerQuery>, QueryDataParameters, DataQuerySettings)
Applies global parameters to inner sub-queries
protected virtual List<string> ApplyGlobalParametersToSubqueries(List<TInnerQuery> queries, QueryDataParameters parameters, DataQuerySettings globalSettings)
  Parameters
queriesList<TInnerQuery>List of queries
parametersQueryDataParametersData parameters for query execution
globalSettingsDataQuerySettingsParameters for the query
Returns
- List<string>
 List of full sub-queries text including resolved parameters.
Exceptions
- NotSupportedException
 Thrown in case of invalid order by column
AsSingleColumn(string, bool)
Creates a single column query from the given query
public override IDataQuery AsSingleColumn(string defaultColumn = null, bool forceColumn = false)
  Parameters
defaultColumnstringSpecific column to use in case query doesn't return single column yet
forceColumnboolIf true, the given column is forced to the output
Returns
AsSubQuery()
Modifies the query to be able to be used as a sub-query, e.g. for usage in WHERE A IN ([query]). Ensures single column result, and removes order by from the result.
public override IDataQuery AsSubQuery()
  Returns
BuildMultiQueryFrom(List<TInnerQuery>, DataQuerySettings)
Builds a multi-query from the given list of queries
protected IDataQuery BuildMultiQueryFrom(List<TInnerQuery> queries, DataQuerySettings globalSettings)
  Parameters
queriesList<TInnerQuery>List of queries
globalSettingsDataQuerySettingsParameters for the query
Returns
CopyPropertiesTo(IQueryObject)
Copies the properties to the target query.
public override void CopyPropertiesTo(IQueryObject target)
  Parameters
targetIQueryObjectTarget query
CreateQuery(string)
Creates query for the given type
protected abstract TInnerQuery CreateQuery(string type)
  Parameters
typestringQuery type
Returns
- TInnerQuery
 
EnsureQueries(IEnumerable<string>)
Ensures the queries for the given types
protected void EnsureQueries(IEnumerable<string> types)
  Parameters
typesIEnumerable<string>Types to ensure
EnsureQueries(params string[])
Ensures the queries for the given types
protected void EnsureQueries(params string[] types)
  Parameters
typesstring[]Types to ensure
EnsureQuery(string)
Ensures the query with the given type
protected virtual TInnerQuery EnsureQuery(string type)
  Parameters
typestringQuery type
Returns
- TInnerQuery
 
GetAvailableColumns()
Gets the list of all available columns for this query
protected override List<string> GetAvailableColumns()
  Returns
- List<string>
 
GetCompleteSettings(IDataQuery)
Gets the complete parameters for the query execution
public override DataQuerySettings GetCompleteSettings(IDataQuery executingQuery = null)
  Parameters
executingQueryIDataQueryExecuting query for which the parameters are retrieved
Returns
GetDefaultSingleColumn()
Gets the default single column for the query
protected override string GetDefaultSingleColumn()
  Returns
- string
 
GetDefaultSource()
Gets the default source
protected override QuerySource GetDefaultSource()
  Returns
GetExecutingQuery(DataQuerySettings)
Gets the query to execute against database
public override IDataQuery GetExecutingQuery(DataQuerySettings settings = null)
  Parameters
settingsDataQuerySettingsParameters for the query
Returns
GetGlobalSettings()
Gets the global settings for the query execution
protected virtual DataQuerySettings GetGlobalSettings()
  Returns
GetMultiQuery(DataQuerySettings)
Gets a multi-query for execution
protected virtual IDataQuery GetMultiQuery(DataQuerySettings settings)
  Parameters
settingsDataQuerySettingsParameters for the query
Returns
GetQueriesForMultiQuery()
Gets the list of queries for multi query
protected List<TInnerQuery> GetQueriesForMultiQuery()
  Returns
- List<TInnerQuery>
 
GetSingleInnerQuery()
Attempts to get a single query if multi-query is defined only by a single query
protected virtual TInnerQuery GetSingleInnerQuery()
  Returns
- TInnerQuery
 
GetSingleQuery(DataQuerySettings)
Attempts to get a single query for the whole result based on the current state of the query object
protected virtual IDataQuery GetSingleQuery(DataQuerySettings globalSettings)
  Parameters
globalSettingsDataQuerySettingsParameters for the query
Returns
GetTypesWhereCondition(IEnumerable<string>)
Returns the where condition which filters the default query data for specific types
protected virtual string GetTypesWhereCondition(IEnumerable<string> types)
  Parameters
typesIEnumerable<string>List of types for which create the where condition
Returns
- string
 
NewDataSet()
Creates a new DataSet for the query results
protected virtual DataSet NewDataSet()
  Returns
- DataSet
 
NoDefaultColumns()
Sets the query to return no columns at all
public virtual TQuery NoDefaultColumns()
  Returns
- TQuery
 
ResolveType(string)
Resolves the given type into corresponding types
protected virtual List<string> ResolveType(string type)
  Parameters
typestringSource type
Returns
- List<string>
 
ResultColumn(IQueryColumn)
Sets the column to select
public virtual TQuery ResultColumn(IQueryColumn column)
  Parameters
columnIQueryColumnColumn to set to be selected
Returns
- TQuery
 
ResultColumn(string)
Sets the column to select
public virtual TQuery ResultColumn(string column)
  Parameters
columnstringColumn to set to be selected
Returns
- TQuery
 
ResultColumns(params IQueryColumn[])
Sets the columns to select
public virtual TQuery ResultColumns(params IQueryColumn[] columns)
  Parameters
columnsIQueryColumn[]Columns to set to be selected
Returns
- TQuery
 
ResultColumns(IEnumerable<string>)
Sets the columns to select
public virtual TQuery ResultColumns(IEnumerable<string> columns)
  Parameters
columnsIEnumerable<string>Columns to set to be selected
Returns
- TQuery
 
ResultColumns(params string[])
Sets the columns to select
public virtual TQuery ResultColumns(params string[] columns)
  Parameters
columnsstring[]Columns to set to be selected
Returns
- TQuery
 
ResultOrderBy(OrderDirection, params string[])
Adds the columns to the order by query
public virtual TQuery ResultOrderBy(OrderDirection dir, params string[] columns)
  Parameters
dirOrderDirectionOrder direction
columnsstring[]Columns to add to order by
Returns
- TQuery
 
ResultOrderBy(params string[])
Adds the columns to the order by query
public virtual TQuery ResultOrderBy(params string[] columns)
  Parameters
columnsstring[]Columns to add to order by
Returns
- TQuery
 
ResultOrderByAscending(params string[])
Adds the columns to the order by query to order by the given columns in ascending order
public virtual TQuery ResultOrderByAscending(params string[] columns)
  Parameters
columnsstring[]Columns to add to order by
Returns
- TQuery
 
ResultOrderByDescending(params string[])
Adds the columns to the order by query to order by the given columns in descending order
public virtual TQuery ResultOrderByDescending(params string[] columns)
  Parameters
columnsstring[]Columns to add to order by
Returns
- TQuery
 
SetClassName(string)
Sets class name for current query
protected override void SetClassName(string value)
  Parameters
valuestringNew class name value
Type(string, Action<TInnerQuery>)
Includes given type with optional parameters. When additional parameters are specified, the query always executes using sub-queries for individual types. If only type is specified, the query allows usage of the default query and additional data from sub-queries may not be included.
public virtual TQuery Type(string type, Action<TInnerQuery> parameters = null)
  Parameters
typestringType to include
parametersAction<TInnerQuery>Action to setup the inner type parameters
Returns
- TQuery
 
Types(params string[])
Includes the given types to the resulting query
public virtual TQuery Types(params string[] types)
  Parameters
typesstring[]Types to include
Returns
- TQuery
 
WithSource(DataQuerySource)
Sets the given source as the source of the data query
public override TQuery WithSource(DataQuerySource source)
  Parameters
sourceDataQuerySourceData query source
Returns
- TQuery