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 | |
---|---|---|
SqlBuilder() | Initializes a new instance of the SqlBuilder class. | |
SqlBuilder(String, Object[]) | Initializes a new instance of the SqlBuilder class using the provided format string and parameters. |
Properties
Name | Description | |
---|---|---|
Buffer | The underlying StringBuilder. | |
CurrentClause | Gets or sets the current SQL clause, used to identify consecutive appends to the same clause. | |
CurrentSeparator | Gets or sets the separator of the current SQL clause body. | |
IsEmpty | Returns true if the buffer is empty. | |
NextClause | Gets or sets the next SQL clause. Used by clause continuation methods, such as AppendToCurrentClause(String, Object[]) and the methods that start with “_”. | |
NextSeparator | Gets or sets the separator of the next SQL clause body. | |
ParameterValues | The parameter objects to be included in the database command. |
Methods
Name | Description | |
---|---|---|
_ | Appends format to the current clause. This method is a shortcut for AppendToCurrentClause(String, Object[]). | |
_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. | |
_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. | |
_ForEach<T> | Appends to the current clause the string made by concatenating an itemFormat for each element in items, interspersed with separator. | |
_If | Appends format to the current clause if condition is true. | |
_OR<T> | Appends to the current clause the string made by concatenating an itemFormat for each element in items, interspersed with the OR operator. | |
Append(SqlBuilder) | Appends sql to this instance. | |
Append(String, Object[]) | Appends format to this instance. | |
AppendClause | Appends the SQL clause specified by clauseName using the provided format string and parameters. | |
AppendLine | Appends the default line terminator to this instance. | |
AppendToCurrentClause | Appends format to the current clause. | |
Clone | Creates and returns a copy of this instance. | |
CROSS_JOIN | Appends the CROSS JOIN clause using the provided format string and parameters. | |
DELETE_FROM | Appends the DELETE FROM clause using the provided format string and parameters. | |
FROM(String, Object[]) | Appends the FROM clause using the provided format string and parameters. | |
FROM(SqlBuilder, String) | Appends the FROM clause using the provided subQuery as body named after alias. | |
FROM(SqlSet, String) | Appends the FROM clause using the provided subQuery as body named after alias. | |
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[]). | |
GROUP_BY(String, Object[]) | Appends the GROUP BY clause using the provided format string and parameters. | |
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[]). | |
HAVING(String, Object[]) | Appends the HAVING clause using the provided format string and parameters. | |
INNER_JOIN | Appends the INNER JOIN clause using the provided format string and parameters. | |
Insert | Inserts a string into this instance at the specified character position. | |
INSERT_INTO | Appends the INSERT INTO clause using the provided format string and parameters. | |
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[]). | |
JOIN(String, Object[]) | Appends the JOIN clause using the provided format string and parameters. | |
JoinSql(String, SqlBuilder[]) | Concatenates a specified separator String between each element of a specified SqlBuilder array, yielding a single concatenated SqlBuilder. | |
JoinSql(String, IEnumerable<SqlBuilder>) | Concatenates the members of a constructed IEnumerable<T> collection of type SqlBuilder, using the specified separator between each member. | |
LEFT_JOIN | Appends the LEFT JOIN clause using the provided format string and parameters. | |
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[]). | |
LIMIT(Int32) | Appends the LIMIT clause using the provided maxRecords parameter. | |
LIMIT(String, Object[]) | Appends the LIMIT clause using the provided format string and parameters. | |
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[]). | |
OFFSET(Int32) | Appends the OFFSET clause using the provided startIndex parameter. | |
OFFSET(String, Object[]) | Appends the OFFSET clause using the provided format string and parameters. | |
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[]). | |
ORDER_BY(String, Object[]) | Appends the ORDER BY clause using the provided format string and parameters. | |
RIGHT_JOIN | Appends the RIGHT JOIN clause using the provided format string and parameters. | |
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[]). | |
SELECT(String, Object[]) | Appends the SELECT clause using the provided format string and parameters. | |
SET | Appends the SET clause using the provided format string and parameters. | |
SetCurrentClause | Sets clauseName as the current SQL clause. | |
SetNextClause | Sets clauseName as the next SQL clause. | |
ToString | Converts the value of this instance to a String. (Overrides Object.ToString().) | |
UNION | Appends the UNION clause. | |
UPDATE | Appends the UPDATE clause using the provided format string and parameters. | |
VALUES | Appends the VALUES clause using the provided parameters. | |
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[]). | |
WHERE(String, Object[]) | Appends the WHERE clause using the provided format string and parameters. | |
WITH(String, Object[]) | Appends the WITH clause using the provided format string and parameters. | |
WITH(SqlBuilder, String) | Appends the WITH clause using the provided subQuery as body named after alias. | |
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.