SqlBuilder Class

Represents a mutable SQL string.

Inheritance Hierarchy

System.Object
  DbExtensions.SqlBuilder

Namespace:  DbExtensions
Assembly: DbExtensions.dll

Syntax

public class SqlBuilder

The SqlBuilder type exposes the following members.

Constructors

  Name Description
Public method SqlBuilder() Initializes a new instance of the SqlBuilder class.
Public method SqlBuilder(String, Object[]) Initializes a new instance of the SqlBuilder class using the provided format string and parameters.

Properties

  Name Description
Public property Buffer The underlying StringBuilder.
Public property CurrentClause Gets or sets the current SQL clause, used to identify consecutive appends to the same clause.
Public property CurrentSeparator Gets or sets the separator of the current SQL clause body.
Public property IsEmpty Returns true if the buffer is empty.
Public property NextClause Gets or sets the next SQL clause. Used by clause continuation methods, such as AppendToCurrentClause(String, Object[]) and the methods that start with “_”.
Public property NextSeparator Gets or sets the separator of the next SQL clause body.
Public property ParameterValues The parameter objects to be included in the database command.

Methods

  Name Description
Public method _ Appends format to the current clause. This method is a shortcut for AppendToCurrentClause(String, Object[]).
Public method _Else Appends format to the current clause if an antecedent call to _If(Boolean, String, Object[]) or _ElseIf(Boolean, String, Object[]) used a false condition.
Public method _ElseIf Appends format to the current clause if condition is true and an antecedent call to _If(Boolean, String, Object[]) or _ElseIf(Boolean, String, Object[]) used a false condition.
Public method _ForEach<T> Appends to the current clause the string made by concatenating an itemFormat for each element in items, interspersed with separator.
Public method _If Appends format to the current clause if condition is true.
Public method _OR<T> Appends to the current clause the string made by concatenating an itemFormat for each element in items, interspersed with the OR operator.
Public method Append(SqlBuilder) Appends sql to this instance.
Public method Append(String, Object[]) Appends format to this instance.
Public method AppendClause Appends the SQL clause specified by clauseName using the provided format string and parameters.
Public method AppendLine Appends the default line terminator to this instance.
Public method AppendToCurrentClause Appends format to the current clause.
Public method Clone Creates and returns a copy of this instance.
Public method CROSS_JOIN Appends the CROSS JOIN clause using the provided format string and parameters.
Public method DELETE_FROM Appends the DELETE FROM clause using the provided format string and parameters.
Public method FROM(String, Object[]) Appends the FROM clause using the provided format string and parameters.
Public method FROM(SqlBuilder, String) Appends the FROM clause using the provided subQuery as body named after alias.
Public method FROM(SqlSet, String) Appends the FROM clause using the provided subQuery as body named after alias.
Public method GROUP_BY() Sets GROUP BY as the next clause, to be used by subsequent calls to clause continuation methods, such as _(String, Object[]) and _If(Boolean, String, Object[]).
Public method GROUP_BY(String, Object[]) Appends the GROUP BY clause using the provided format string and parameters.
Public method HAVING() Sets HAVING as the next clause, to be used by subsequent calls to clause continuation methods, such as _(String, Object[]) and _If(Boolean, String, Object[]).
Public method HAVING(String, Object[]) Appends the HAVING clause using the provided format string and parameters.
Public method INNER_JOIN Appends the INNER JOIN clause using the provided format string and parameters.
Public method Insert Inserts a string into this instance at the specified character position.
Public method INSERT_INTO Appends the INSERT INTO clause using the provided format string and parameters.
Public method JOIN() Sets JOIN as the next clause, to be used by subsequent calls to clause continuation methods, such as _(String, Object[]) and _If(Boolean, String, Object[]).
Public method JOIN(String, Object[]) Appends the JOIN clause using the provided format string and parameters.
Public methodStatic member JoinSql(String, SqlBuilder[]) Concatenates a specified separator String between each element of a specified SqlBuilder array, yielding a single concatenated SqlBuilder.
Public methodStatic member JoinSql(String, IEnumerable<SqlBuilder>) Concatenates the members of a constructed IEnumerable<T> collection of type SqlBuilder, using the specified separator between each member.
Public method LEFT_JOIN Appends the LEFT JOIN clause using the provided format string and parameters.
Public method LIMIT() Sets LIMIT as the next clause, to be used by subsequent calls to clause continuation methods, such as _(String, Object[]) and _If(Boolean, String, Object[]).
Public method LIMIT(Int32) Appends the LIMIT clause using the provided maxRecords parameter.
Public method LIMIT(String, Object[]) Appends the LIMIT clause using the provided format string and parameters.
Public method OFFSET() Sets OFFSET as the next clause, to be used by subsequent calls to clause continuation methods, such as _(String, Object[]) and _If(Boolean, String, Object[]).
Public method OFFSET(Int32) Appends the OFFSET clause using the provided startIndex parameter.
Public method OFFSET(String, Object[]) Appends the OFFSET clause using the provided format string and parameters.
Public method ORDER_BY() Sets ORDER BY as the next clause, to be used by subsequent calls to clause continuation methods, such as _(String, Object[]) and _If(Boolean, String, Object[]).
Public method ORDER_BY(String, Object[]) Appends the ORDER BY clause using the provided format string and parameters.
Public method RIGHT_JOIN Appends the RIGHT JOIN clause using the provided format string and parameters.
Public method SELECT() Sets SELECT as the next clause, to be used by subsequent calls to clause continuation methods, such as _(String, Object[]) and _If(Boolean, String, Object[]).
Public method SELECT(String, Object[]) Appends the SELECT clause using the provided format string and parameters.
Public method SET Appends the SET clause using the provided format string and parameters.
Public method SetCurrentClause Sets clauseName as the current SQL clause.
Public method SetNextClause Sets clauseName as the next SQL clause.
Public method ToString Converts the value of this instance to a String. (Overrides Object.ToString().)
Public method UNION Appends the UNION clause.
Public method UPDATE Appends the UPDATE clause using the provided format string and parameters.
Public method VALUES Appends the VALUES clause using the provided parameters.
Public method WHERE() Sets WHERE as the next clause, to be used by subsequent calls to clause continuation methods, such as _(String, Object[]) and _If(Boolean, String, Object[]).
Public method WHERE(String, Object[]) Appends the WHERE clause using the provided format string and parameters.
Public method WITH(String, Object[]) Appends the WITH clause using the provided format string and parameters.
Public method WITH(SqlBuilder, String) Appends the WITH clause using the provided subQuery as body named after alias.
Public method WITH(SqlSet, String) Appends the WITH clause using the provided subQuery as body named after alias.

Remarks

For information on how to use SqlBuilder see SqlBuilder Tutorial.

See Also

Reference

DbExtensions Namespace

© Max Toro Q.