SelectContextBase
Shared facade over a.
Every dialect accumulates the same statement-builder calls; only base-table/alias
handling and final SQL rendering differ. Implements [DP-SQL-MODEL-DIALECTS].
public abstract class SelectContextBase : ISqlContext
Properties
Builder
protected SelectStatementBuilder Builder { get; }
Gets the statement builder this dialect context accumulates into.
HasJoins
public bool HasJoins { get; }
Gets a value indicating whether this query has joins
Methods
SetSelectColumns(IEnumerable<ColumnInfo>, bool)
public void SetSelectColumns(IEnumerable<ColumnInfo> columns, bool distinct = false)
Sets the SELECT columns for the query
Parameters:
| Name | Type | Description |
|---|---|---|
columns |
ColumnInfo> |
The columns to select |
distinct |
Boolean |
Whether to use DISTINCT |
AddWhereCondition(WhereCondition)
public void AddWhereCondition(WhereCondition condition)
Adds a WHERE condition
Parameters:
| Name | Type | Description |
|---|---|---|
condition |
WhereCondition |
The condition to add |
AddGroupBy(IEnumerable<ColumnInfo>)
public void AddGroupBy(IEnumerable<ColumnInfo> columns)
Adds GROUP BY columns
Parameters:
| Name | Type | Description |
|---|---|---|
columns |
ColumnInfo> |
The columns to group by |
AddOrderBy(IEnumerable<(string Column, string Direction)>)
public void AddOrderBy(IEnumerable<(string Column, string Direction)> orderItems)
Adds ORDER BY items
Parameters:
| Name | Type | Description |
|---|---|---|
orderItems |
String>> |
The order items (column, direction) |
AddHaving(string)
public virtual void AddHaving(string condition)
Adds a HAVING condition
Parameters:
| Name | Type | Description |
|---|---|---|
condition |
String |
The having condition |
SetLimit(string)
public void SetLimit(string count)
Sets the LIMIT (or TOP for SQL Server)
Parameters:
| Name | Type | Description |
|---|---|---|
count |
String |
The limit count |
SetOffset(string)
public void SetOffset(string count)
Sets the OFFSET
Parameters:
| Name | Type | Description |
|---|---|---|
count |
String |
The offset count |
AddUnion(string, bool)
public void AddUnion(string query, bool isUnionAll)
Adds a UNION or UNION ALL
Parameters:
| Name | Type | Description |
|---|---|---|
query |
String |
The query to union with |
isUnionAll |
Boolean |
Whether this is UNION ALL |
SetBaseTable(string)
public abstract void SetBaseTable(string tableName)
Sets the base table for the query
Parameters:
| Name | Type | Description |
|---|---|---|
tableName |
String |
The base table name |
AddJoin(string, string, string?)
public abstract void AddJoin(string joinType, string tableName, string? condition)
Adds a JOIN to the query
Parameters:
| Name | Type | Description |
|---|---|---|
joinType |
String |
The type of join (INNER JOIN, LEFT JOIN, etc.) |
tableName |
String |
The table to join |
condition |
String |
The join condition |
GenerateSQL()
public abstract string GenerateSQL()
Generates the final SQL query
Returns: String - The SQL query string