Class Select
Query to select data.
Inherited Members
Namespace: Terrasoft.Core.DB
Assembly: Terrasoft.Core.dll
Syntax
public class Select : Query, IParametrizedQuery, ISqlGenerating, ICacheableQuery, ICloneable, IDBReadableCommand
Constructors
Select(Select)
Initializes a new Select instance that is a clone of the passed-in query.
Declaration
public Select(Select source)
Parameters
Type | Name | Description |
---|---|---|
Select | source | The data select query whose clone is being created. |
Select(UserConnection)
Initialises a new instance of Select, using given user's connection.
Declaration
public Select(UserConnection userConnection)
Parameters
Type | Name | Description |
---|---|---|
UserConnection | userConnection | User's connection. |
Select(UserConnection, CancellationToken)
Initialises a new instance of Select, using given user's connection and a System.Threading.CancellationToken.
Declaration
public Select(UserConnection userConnection, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
UserConnection | userConnection | User's connection. |
System.Threading.CancellationToken | cancellationToken | Cancellation token to be passed to requests. |
Properties
CanReadUncommitedData
Determines whether the query results will include the data for which the transaction is not completed.
Declaration
public bool CanReadUncommitedData { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Columns
Collection of expressions of query columns.
Declaration
public QueryColumnExpressionCollection Columns { get; }
Property Value
Type | Description |
---|---|
QueryColumnExpressionCollection |
ConnectBySelect
ConnectBy select. Using for pageable hierarchical queries. Select.
Declaration
public Select ConnectBySelect { get; set; }
Property Value
Type | Description |
---|---|
Select |
HierarchicalOptions
Parameters for building hierarchical queries. HierarchicalSelectOptions.
Declaration
public HierarchicalSelectOptions HierarchicalOptions { get; set; }
Property Value
Type | Description |
---|---|
HierarchicalSelectOptions |
IsDistinct
Determines whether the query returns only unique records.
Declaration
public bool IsDistinct { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
OffsetFetchPaging
Determines if offset-fetch paging is using.
Declaration
public bool OffsetFetchPaging { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
PageableOptions
Parameters for paging query results. PageableSelectOptions.
Declaration
public PageableSelectOptions PageableOptions { get; set; }
Property Value
Type | Description |
---|---|
PageableSelectOptions |
QueryKind
Query kind, that is used to request special executor.
Declaration
public QueryKind QueryKind { get; }
Property Value
Type | Description |
---|---|
QueryKind |
QueryOptimize
Additional information about the query, that can by use to optimization DBEngine.
Declaration
public bool QueryOptimize { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
RowsOffset
Number of rows to skip.
Declaration
public int RowsOffset { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
SourceExpression
The expression of the query data source.
Declaration
public QuerySourceExpression SourceExpression { get; set; }
Property Value
Type | Description |
---|---|
QuerySourceExpression |
Methods
AddColumn(QueryColumnExpression)
Declaration
protected void AddColumn(QueryColumnExpression columnExpression)
Parameters
Type | Name | Description |
---|---|---|
QueryColumnExpression | columnExpression |
AddFrom(QuerySourceExpression)
Declaration
protected void AddFrom(QuerySourceExpression sourceExpression)
Parameters
Type | Name | Description |
---|---|---|
QuerySourceExpression | sourceExpression |
As(String)
Adds the specified alias for the last specified query expression.
Declaration
public Select As(string alias)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias | The query expression alias. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
Exceptions
Type | Condition |
---|---|
InvalidObjectStateException | If the method is called before calling one of the [From] or [Columns] methods. |
BuildSqlText(StringBuilder)
Generates the query text, using the specified System.Text.StringBuilder instance.
Declaration
public override void BuildSqlText(StringBuilder sb)
Parameters
Type | Name | Description |
---|---|---|
System.Text.StringBuilder | sb | The System.Text.StringBuilder instance used to create query text. |
Overrides
Clone()
Creates the clone of the current Select instance.
Declaration
public override object Clone()
Returns
Type | Description |
---|---|
System.Object | A new Select instance that represents the copy of the current instance. |
Overrides
Column(String)
In the collection of column expressions of the current query, adds an expression for the column with the specified alias.
Declaration
public Select Column(string sourceColumnAlias)
Parameters
Type | Name | Description |
---|---|---|
System.String | sourceColumnAlias | The alias of the column. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
Column(String, String)
In the collection of column expressions of the current query, adds an expression for the column with the specified alias from the specified source.
Declaration
public Select Column(string sourceAlias, string sourceColumnAlias)
Parameters
Type | Name | Description |
---|---|---|
System.String | sourceAlias | The alias of the source. |
System.String | sourceColumnAlias | The alias of the column. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
Column(IQueryColumnExpressionConvertible)
Adds the passed-in expression in the current collection of column expressions.
Declaration
public Select Column(IQueryColumnExpressionConvertible expression)
Parameters
Type | Name | Description |
---|---|---|
IQueryColumnExpressionConvertible | expression | Expression. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
Column(Query)
In the collection of column expressions of the current query, adds an expression for the passed-in random subquery.
Declaration
public Select Column(Query subSelectQuery)
Parameters
Type | Name | Description |
---|---|---|
Query | subSelectQuery | Random subquery. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
Column(QueryCase)
In the collection of column expressions of the current query, adds an expression for the passed-in Case operator.
Declaration
public Select Column(QueryCase queryCase)
Parameters
Type | Name | Description |
---|---|---|
QueryCase | queryCase | The Case query operator. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
Column(QueryColumnExpression)
Adds the passed-in column expression in the current collection of column expressions.
Declaration
public Select Column(QueryColumnExpression columnExpression)
Parameters
Type | Name | Description |
---|---|---|
QueryColumnExpression | columnExpression | The query column expression. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
Column(QueryParameter)
In the current collection of column expressions, adds the expressions for the passed-in query parameter.
Declaration
public Select Column(QueryParameter queryParameter)
Parameters
Type | Name | Description |
---|---|---|
QueryParameter | queryParameter | The query parameter. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
Column(Select)
In the collection of column expressions of the current query, adds an expression for the passed-in select subquery.
Declaration
public Select Column(Select subSelect)
Parameters
Type | Name | Description |
---|---|---|
Select | subSelect | The select subquery. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
CrossJoin(String)
Associates the schema with the specified name with the current query, using the cross join.
Declaration
public Select CrossJoin(string schemaName)
Parameters
Type | Name | Description |
---|---|---|
System.String | schemaName | Name of the schema to associate. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
CrossJoin(Query)
Associates the specified random subquery with the current query, using the cross join.
Declaration
public Select CrossJoin(Query subSelectQuery)
Parameters
Type | Name | Description |
---|---|---|
Query | subSelectQuery | Random subquery. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
CrossJoin(QuerySourceExpression)
Associates the specified expression with the current query, using the cross join.
Declaration
public Select CrossJoin(QuerySourceExpression sourceExpression)
Parameters
Type | Name | Description |
---|---|---|
QuerySourceExpression | sourceExpression | Expression for the data source being attached. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
CrossJoin(Select)
Associates the specified select subquery with the current query, using the cross join.
Declaration
public Select CrossJoin(Select subSelect)
Parameters
Type | Name | Description |
---|---|---|
Select | subSelect | The select subquery. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
Distinct()
To the current select query, adds the key word Distinct.
Declaration
public Select Distinct()
Returns
Type | Description |
---|---|
Select | The current Select instance. |
EnsureSpecialDBExecutor(UserConnection, QueryKind)
Declaration
protected DBExecutor EnsureSpecialDBExecutor(UserConnection userConnection, QueryKind queryKind)
Parameters
Type | Name | Description |
---|---|---|
UserConnection | userConnection | |
QueryKind | queryKind |
Returns
Type | Description |
---|---|
DBExecutor |
ExecuteReader(DBExecutor)
Executes SQL query using given instance of DBExecutor and returns System.Data.IDataReader for the resulting set of records.
Declaration
public IDataReader ExecuteReader(DBExecutor dbExecutor)
Parameters
Type | Name | Description |
---|---|---|
DBExecutor | dbExecutor | Instance of DBExecutor, to be used for SQL query. |
Returns
Type | Description |
---|---|
System.Data.IDataReader | Instance implementing System.Data.IDataReader for the resulting set of records. |
ExecuteReader(DBExecutor, CommandBehavior)
Executes SQL query using given instance of DBExecutor and returns System.Data.IDataReader for the resulting set of records.
Declaration
public IDataReader ExecuteReader(DBExecutor dbExecutor, CommandBehavior behavior)
Parameters
Type | Name | Description |
---|---|---|
DBExecutor | dbExecutor | Instance of DBExecutor, to be used for SQL query. |
System.Data.CommandBehavior | behavior | Provides a description of the results of the query and its effect on the database. |
Returns
Type | Description |
---|---|
System.Data.IDataReader | Instance implementing System.Data.IDataReader for the resulting set of records. |
ExecuteReader(Select.ExecuteReaderReadMethod)
Executes SQL query and executes delegate Select.ExecuteReaderReadMethod for each row of the resulting set of records.
Declaration
public void ExecuteReader(Select.ExecuteReaderReadMethod readMethod)
Parameters
Type | Name | Description |
---|---|---|
Select.ExecuteReaderReadMethod | readMethod |
ExecuteScalar<TResult>()
Executes the query and returns the first column of the first row in the result set returned by the query.
Declaration
public TResult ExecuteScalar<TResult>()
Returns
Type | Description |
---|---|
TResult | The first row in the result set of type |
Type Parameters
Name | Description |
---|---|
TResult | The type of the return value. |
ExecuteScalar<TResult>(DBExecutor)
Executes the current select query and returns the typed first column of the first record of the resulting set, using the passed-in DBExecutor instance.
Declaration
public TResult ExecuteScalar<TResult>(DBExecutor dbExecutor)
Parameters
Type | Name | Description |
---|---|---|
DBExecutor | dbExecutor | The DBExecutor instance used to query the database. |
Returns
Type | Description |
---|---|
TResult | The first column of the first record in the resulting dataset of the |
Type Parameters
Name | Description |
---|---|
TResult | The return type of the column value. |
ExecuteScalarAsync<TResult>()
An asynchronous version of ExecuteScalar, which executes the query and returns the first column of the first row in the result set returned by the query.
Declaration
public Task<TResult> ExecuteScalarAsync<TResult>()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResult> | A task representing the asynchronous operation. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the return value. |
From(String)
Adds the schema with the specified name as the data source expression of the current query.
Declaration
public Select From(string schemaName)
Parameters
Type | Name | Description |
---|---|---|
System.String | schemaName | Name of the schema. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
From(Query)
Adds the expression for the transferred arbitrary subquery as the data source expression of the current query.
Declaration
public Select From(Query subSelectQuery)
Parameters
Type | Name | Description |
---|---|---|
Query | subSelectQuery | Random subquery. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
From(QuerySourceExpression)
Adds the passed-in expression as the data source expression of the current query.
Declaration
public Select From(QuerySourceExpression sourceExpression)
Parameters
Type | Name | Description |
---|---|---|
QuerySourceExpression | sourceExpression | The expression of the query data source. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
From(Select)
Adds the expression for the passed-in select subquery as the data source expression of the current query.
Declaration
public Select From(Select subSelect)
Parameters
Type | Name | Description |
---|---|---|
Select | subSelect | The select subquery. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
GetSqlText()
Returns the SQL text of the current query.
Declaration
public override string GetSqlText()
Returns
Type | Description |
---|---|
System.String | The SQL text of the current query. |
Overrides
GetUsingParameters()
Returns the collection of parameters used by the query.
Declaration
public override QueryParameterCollection GetUsingParameters()
Returns
Type | Description |
---|---|
QueryParameterCollection | Collection of parameters used by the query. |
Overrides
OffsetFetch(Int32, Int32)
Adds offset-fetch clause to select.
Declaration
public Select OffsetFetch(int rowsOffset, int rowsCount)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowsOffset | Number of rows to skip. |
System.Int32 | rowsCount | Number of rows to select. |
Returns
Type | Description |
---|---|
Select | Modified select. |
Top(Int32)
Specifies the number of first records returned by the resulting dataset.
Declaration
public Select Top(int rowCount)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowCount | Number of first records of the resulting set. |
Returns
Type | Description |
---|---|
Select | The current Select instance. |
ToPageable(PageableSelectOptions)
Transforms the current query into a query that has an option of the paged output with the specified parameters.
Declaration
public Select ToPageable(PageableSelectOptions options)
Parameters
Type | Name | Description |
---|---|---|
PageableSelectOptions | options | Parameters of the paged output of the query results. |
Returns
Type | Description |
---|---|
Select | The data select query with the paged output. |