SQLiteContext
Context for building SQLite queries with proper table aliases and structure
public sealed class SQLiteContext : ISqlContext
Constructors
SQLiteContext
public SQLiteContext()
Initializes a new instance of the SQLiteContext class
Properties
HasJoins
public bool HasJoins { get; }
Gets a value indicating whether this query has joins
Methods
SetBaseTable(string)
public 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 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)
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 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
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 |
GenerateSQL()
public string GenerateSQL()
Generates the final SQL query
Returns: String - The SQL query string
ProcessPipeline(Pipeline)
public string ProcessPipeline(Pipeline pipeline)
Processes a pipeline and returns the generated SQL
Parameters:
| Name | Type | Description |
|---|---|---|
pipeline |
Pipeline |
The pipeline to process |
Returns: String - The generated SQLite SQL
ToSQLiteSql(SelectStatement)
public static string ToSQLiteSql(SelectStatement statement)
Public helper to generate SQLite SQL from an existing SelectStatement
Parameters:
| Name | Type | Description |
|---|---|---|
statement |
SelectStatement |
The statement to generate SQL for |
Returns: String - SQLite SQL string