C# Класс ScrewTurn.Wiki.Plugins.SqlCommon.QueryBuilder

A tool for building queries.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AndWhere ( string query, string column, WhereOperator op, string parameter ) : string

Adds another WHERE clause to a query.

AndWhere ( string query, string column, WhereOperator op, string parameter, bool openBracket, bool closeBracket ) : string

Adds another WHERE clause to a query.

AndWhere ( string query, string table, string column, WhereOperator op, string parameter ) : string

Adds another WHERE clause to a query.

AndWhere ( string query, string table, string column, WhereOperator op, string parameter, bool openBracket, bool closeBracket ) : string

Adds another WHERE clause to a query.

AppendForBatch ( string query, string secondQuery ) : string

Appends a query to an existing query for batch execution.

DeleteFrom ( string table ) : string

Builds a DELETE FROM query.

GroupBy ( string query, string columns ) : string

Applies a GROUP BY clause to a query.

InsertInto ( string table, string columns, string parameters ) : string

Builds an INSERT INTO query.

NewQuery ( ICommandBuilder builder ) : QueryBuilder

Initializes a new instance of the T:QueryBuilder class.

OrWhere ( string query, string column, WhereOperator op, string parameter ) : string

Adds another WHERE clause to a query.

OrWhere ( string query, string column, WhereOperator op, string parameter, bool openBracket, bool closeBracket ) : string

Adds another WHERE clause to a query.

OrWhere ( string query, string table, string column, WhereOperator op, string parameter ) : string

Adds another WHERE clause to a query.

OrWhere ( string query, string table, string column, WhereOperator op, string parameter, bool openBracket, bool closeBracket ) : string

Adds another WHERE clause to a query.

OrderBy ( string query, string columns, Ordering orderings ) : string

Applies an ORDER BY clause to a query.

QueryBuilder ( ICommandBuilder builder ) : System

Initializes a new instance of the T:QueryBuilder class.

SelectCountFrom ( string table ) : string

Builds a SELECT COUNT(*) query.

SelectFrom ( string table ) : string

Builds a SELECT query.

SelectFrom ( string table, string columns ) : string

Builds a SELECT query.

SelectFrom ( string table, string joinedTable, string tableColumn, string joinedTableColumn, Join join ) : string

Builds a SELECT query with a JOIN clause.

SelectFrom ( string table, string joinedTable, string tableColumn, string joinedTableColumn, Join join, string tableColumns, string joinedTableColumns ) : string

Builds a SELECT query with a JOIN clause.

SelectFrom ( string table, string joinedTable, string tableColumn, string joinedTableColumn, Join join, string tableColumns, string joinedTableColumns, string otherJoinedTable, string otherJoinedTableColumn, Join otherJoin, string otherJoinedTableColumns ) : string

Builds a SELECT query with two JOIN clauses (both on the main table).

Update ( string table, string columns, string parameters ) : string

Builds an UPDATE query.

UpdateIncrement ( string table, string column, int increment ) : string

Builds an UPDATE query that increments the numerical value of a column by one.

Where ( string query, string column, WhereOperator op, string parameter ) : string

Applies a WHERE clause to a query.

Where ( string query, string column, WhereOperator op, string parameter, bool openBracket, bool closeBracket ) : string

Applies a WHERE clause to a query.

Where ( string query, string table, string column, WhereOperator op, string parameter ) : string

Applies a WHERE clause to a query.

Where ( string query, string table, string column, WhereOperator op, string parameter, bool openBracket, bool closeBracket ) : string

Applies a WHERE clause to a query.

WhereIn ( string query, string column, string parameters ) : string

Applies a WHERE clause with IN operator to a query.

WhereIn ( string query, string table, string column, string parameters ) : string

Applies a WHERE clause with IN operator to a query.

WhereNotInSubquery ( string query, string table, string column, string subQuery ) : string

Applies a WHERE NOT IN (subQuery) clause to a query.

Приватные методы

Метод Описание
BuildWhereClause ( string table, string column, WhereOperator op, string parameter ) : string

Builds a WHERE clause condition.

BuildWhereInClause ( string table, string column, string parameters ) : string

Builds a WHERE clause with IN operator.

JoinToString ( Join join ) : string

Converts a Join type to its string representation.

OrderingToString ( Ordering ordering ) : string

Converts an ordering to string.

WhereOperatorToString ( WhereOperator op ) : string

Converts a WHERE operator to its corresponding string.

Описание методов

AndWhere() публичный Метод

Adds another WHERE clause to a query.
public AndWhere ( string query, string column, WhereOperator op, string parameter ) : string
query string The query.
column string The column subject of the WHERE clause.
op WhereOperator The operator.
parameter string The name of the parameter for the WHERE clause.
Результат string

AndWhere() публичный Метод

Adds another WHERE clause to a query.
public AndWhere ( string query, string column, WhereOperator op, string parameter, bool openBracket, bool closeBracket ) : string
query string The query.
column string The column subject of the WHERE clause.
op WhereOperator The operator.
parameter string The name of the parameter for the WHERE clause.
openBracket bool A value indicating whether to open a bracket after the AND.
closeBracket bool A value indicating whether to close a bracket after the clause.
Результат string

AndWhere() публичный Метод

Adds another WHERE clause to a query.
public AndWhere ( string query, string table, string column, WhereOperator op, string parameter ) : string
query string The query.
table string The table the column belongs to.
column string The column subject of the WHERE clause.
op WhereOperator The operator.
parameter string The name of the parameter for the WHERE clause.
Результат string

AndWhere() публичный Метод

Adds another WHERE clause to a query.
public AndWhere ( string query, string table, string column, WhereOperator op, string parameter, bool openBracket, bool closeBracket ) : string
query string The query.
table string The table the column belongs to.
column string The column subject of the WHERE clause.
op WhereOperator The operator.
parameter string The name of the parameter for the WHERE clause.
openBracket bool A value indicating whether to open a bracket after the AND.
closeBracket bool A value indicating whether to close a bracket after the clause.
Результат string

AppendForBatch() публичный Метод

Appends a query to an existing query for batch execution.
public AppendForBatch ( string query, string secondQuery ) : string
query string The query.
secondQuery string The second query.
Результат string

DeleteFrom() публичный Метод

Builds a DELETE FROM query.
public DeleteFrom ( string table ) : string
table string The table.
Результат string

GroupBy() публичный Метод

Applies a GROUP BY clause to a query.
public GroupBy ( string query, string columns ) : string
query string The query.
columns string The columns to group by.
Результат string

InsertInto() публичный Метод

Builds an INSERT INTO query.
public InsertInto ( string table, string columns, string parameters ) : string
table string The destination table.
columns string The columns names.
parameters string The parameters names.
Результат string

NewQuery() публичный статический Метод

Initializes a new instance of the T:QueryBuilder class.
public static NewQuery ( ICommandBuilder builder ) : QueryBuilder
builder ICommandBuilder The command builder.
Результат QueryBuilder

OrWhere() публичный Метод

Adds another WHERE clause to a query.
public OrWhere ( string query, string column, WhereOperator op, string parameter ) : string
query string The query.
column string The column subject of the WHERE clause.
op WhereOperator The operator.
parameter string The name of the parameter for the WHERE clause.
Результат string

OrWhere() публичный Метод

Adds another WHERE clause to a query.
public OrWhere ( string query, string column, WhereOperator op, string parameter, bool openBracket, bool closeBracket ) : string
query string The query.
column string The column subject of the WHERE clause.
op WhereOperator The operator.
parameter string The name of the parameter for the WHERE clause.
openBracket bool A value indicating whether to open a bracket after the OR.
closeBracket bool A value indicating whether to close a bracket after the clause.
Результат string

OrWhere() публичный Метод

Adds another WHERE clause to a query.
public OrWhere ( string query, string table, string column, WhereOperator op, string parameter ) : string
query string The query.
table string The table the column belongs to.
column string The column subject of the WHERE clause.
op WhereOperator The operator.
parameter string The name of the parameter for the WHERE clause.
Результат string

OrWhere() публичный Метод

Adds another WHERE clause to a query.
public OrWhere ( string query, string table, string column, WhereOperator op, string parameter, bool openBracket, bool closeBracket ) : string
query string The query.
table string The table the column belongs to.
column string The column subject of the WHERE clause.
op WhereOperator The operator.
parameter string The name of the parameter for the WHERE clause.
openBracket bool A value indicating whether to open a bracket after the AND.
closeBracket bool A value indicating whether to close a bracket after the clause.
Результат string

OrderBy() публичный Метод

Applies an ORDER BY clause to a query.
public OrderBy ( string query, string columns, Ordering orderings ) : string
query string The query.
columns string The columns to order by.
orderings Ordering The ordering directions for each column.
Результат string

QueryBuilder() публичный Метод

Initializes a new instance of the T:QueryBuilder class.
public QueryBuilder ( ICommandBuilder builder ) : System
builder ICommandBuilder The command builder.
Результат System

SelectCountFrom() публичный Метод

Builds a SELECT COUNT(*) query.
public SelectCountFrom ( string table ) : string
table string The table.
Результат string

SelectFrom() публичный Метод

Builds a SELECT query.
public SelectFrom ( string table ) : string
table string The table.
Результат string

SelectFrom() публичный Метод

Builds a SELECT query.
public SelectFrom ( string table, string columns ) : string
table string The table.
columns string The columns to select.
Результат string

SelectFrom() публичный Метод

Builds a SELECT query with a JOIN clause.
public SelectFrom ( string table, string joinedTable, string tableColumn, string joinedTableColumn, Join join ) : string
table string The main table.
joinedTable string The joined table.
tableColumn string The main table column to join.
joinedTableColumn string The joined table column to join.
join Join The JOIN type.
Результат string

SelectFrom() публичный Метод

Builds a SELECT query with a JOIN clause.
public SelectFrom ( string table, string joinedTable, string tableColumn, string joinedTableColumn, Join join, string tableColumns, string joinedTableColumns ) : string
table string The min table.
joinedTable string The joined table.
tableColumn string The main table column to join.
joinedTableColumn string The joined table column to join.
join Join The JOIN type.
tableColumns string The main table columns to select.
joinedTableColumns string The joined table columns to select.
Результат string

SelectFrom() публичный Метод

Builds a SELECT query with two JOIN clauses (both on the main table).
public SelectFrom ( string table, string joinedTable, string tableColumn, string joinedTableColumn, Join join, string tableColumns, string joinedTableColumns, string otherJoinedTable, string otherJoinedTableColumn, Join otherJoin, string otherJoinedTableColumns ) : string
table string The main table.
joinedTable string The joined table.
tableColumn string The main table column to join.
joinedTableColumn string The joined table column to join.
join Join The join.
tableColumns string The main table columns to select.
joinedTableColumns string The joined table columns to select.
otherJoinedTable string The other joined table.
otherJoinedTableColumn string The other joined table column to join.
otherJoin Join The join.
otherJoinedTableColumns string The other joined table columns to select.
Результат string

Update() публичный Метод

Builds an UPDATE query.
public Update ( string table, string columns, string parameters ) : string
table string The table.
columns string The columns to update.
parameters string The parameters.
Результат string

UpdateIncrement() публичный Метод

Builds an UPDATE query that increments the numerical value of a column by one.
public UpdateIncrement ( string table, string column, int increment ) : string
table string The table.
column string The column to update.
increment int The increment or decrement value.
Результат string

Where() публичный Метод

Applies a WHERE clause to a query.
public Where ( string query, string column, WhereOperator op, string parameter ) : string
query string The query.
column string The column subject of the WHERE clause.
op WhereOperator The operator.
parameter string The name of the parameter for the WHERE clause.
Результат string

Where() публичный Метод

Applies a WHERE clause to a query.
public Where ( string query, string column, WhereOperator op, string parameter, bool openBracket, bool closeBracket ) : string
query string The query.
column string The column subject of the WHERE clause.
op WhereOperator The operator.
parameter string The name of the parameter for the WHERE clause.
openBracket bool A value indicating whether to open a bracket after the WHERE.
closeBracket bool A value indicating whether to close a bracket after the clause.
Результат string

Where() публичный Метод

Applies a WHERE clause to a query.
public Where ( string query, string table, string column, WhereOperator op, string parameter ) : string
query string The query.
table string The table the column belongs to.
column string The column subject of the WHERE clause.
op WhereOperator The operator.
parameter string The name of the parameter for the WHERE clause.
Результат string

Where() публичный Метод

Applies a WHERE clause to a query.
public Where ( string query, string table, string column, WhereOperator op, string parameter, bool openBracket, bool closeBracket ) : string
query string The query.
table string The table the column belongs to.
column string The column subject of the WHERE clause.
op WhereOperator The operator.
parameter string The name of the parameter for the WHERE clause.
openBracket bool A value indicating whether to open a bracket after the WHERE.
closeBracket bool A value indicating whether to close a bracket after the clause.
Результат string

WhereIn() публичный Метод

Applies a WHERE clause with IN operator to a query.
public WhereIn ( string query, string column, string parameters ) : string
query string The query.
column string The column subject of the WHERE clause.
parameters string The names of the parameters in the IN set.
Результат string

WhereIn() публичный Метод

Applies a WHERE clause with IN operator to a query.
public WhereIn ( string query, string table, string column, string parameters ) : string
query string The query.
table string The table the column belongs to.
column string The column subject of the WHERE clause.
parameters string The names of the parameters in the IN set.
Результат string

WhereNotInSubquery() публичный Метод

Applies a WHERE NOT IN (subQuery) clause to a query.
public WhereNotInSubquery ( string query, string table, string column, string subQuery ) : string
query string The query.
table string The table the column belongs to.
column string The column.
subQuery string The subQuery.
Результат string