ISqlContext
Interface for SQL context implementations that generate dialect-specific SQL
public interface ISqlContext
Methods
SetBaseTable(string)
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?)
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 |
SetSelectColumns(IEnumerable<ColumnInfo>, bool)
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)
void AddWhereCondition(WhereCondition condition)
Adds a WHERE condition
Parameters:
| Name | Type | Description |
|---|---|---|
condition |
WhereCondition |
The condition to add |
AddGroupBy(IEnumerable<ColumnInfo>)
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)>)
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)
void AddHaving(string condition)
Adds a HAVING condition
Parameters:
| Name | Type | Description |
|---|---|---|
condition |
String |
The having condition |
SetLimit(string)
void SetLimit(string count)
Sets the LIMIT (or TOP for SQL Server)
Parameters:
| Name | Type | Description |
|---|---|---|
count |
String |
The limit count |
SetOffset(string)
void SetOffset(string count)
Sets the OFFSET
Parameters:
| Name | Type | Description |
|---|---|---|
count |
String |
The offset count |
AddUnion(string, bool)
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 |
GenerateSQL()
string GenerateSQL()
Generates the final SQL query
Returns: String - The SQL query string