C# Class ScrewTurn.Wiki.Plugins.SqlCommon.QueryBuilder

A tool for building queries.
Mostra file Open project: mono/ScrewTurnWiki Class Usage Examples

Public Methods

Method Description
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.

Private Methods

Method Description
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.

Method Details

AndWhere() public method

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.
return string

AndWhere() public method

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.
return string

AndWhere() public method

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.
return string

AndWhere() public method

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.
return string

AppendForBatch() public method

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.
return string

DeleteFrom() public method

Builds a DELETE FROM query.
public DeleteFrom ( string table ) : string
table string The table.
return string

GroupBy() public method

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.
return string

InsertInto() public method

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.
return string

NewQuery() public static method

Initializes a new instance of the T:QueryBuilder class.
public static NewQuery ( ICommandBuilder builder ) : QueryBuilder
builder ICommandBuilder The command builder.
return QueryBuilder

OrWhere() public method

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.
return string

OrWhere() public method

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.
return string

OrWhere() public method

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.
return string

OrWhere() public method

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.
return string

OrderBy() public method

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.
return string

QueryBuilder() public method

Initializes a new instance of the T:QueryBuilder class.
public QueryBuilder ( ICommandBuilder builder ) : System
builder ICommandBuilder The command builder.
return System

SelectCountFrom() public method

Builds a SELECT COUNT(*) query.
public SelectCountFrom ( string table ) : string
table string The table.
return string

SelectFrom() public method

Builds a SELECT query.
public SelectFrom ( string table ) : string
table string The table.
return string

SelectFrom() public method

Builds a SELECT query.
public SelectFrom ( string table, string columns ) : string
table string The table.
columns string The columns to select.
return string

SelectFrom() public method

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.
return string

SelectFrom() public method

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.
return string

SelectFrom() public method

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.
return string

Update() public method

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.
return string

UpdateIncrement() public method

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.
return string

Where() public method

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.
return string

Where() public method

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.
return string

Where() public method

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.
return string

Where() public method

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.
return string

WhereIn() public method

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.
return string

WhereIn() public method

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.
return string

WhereNotInSubquery() public method

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.
return string