Class QueryBuilder
- Namespace
- FluentCommand.Query
- Assembly
- FluentCommand.dll
Provides a high-level builder for constructing and composing multiple SQL query statements.
public class QueryBuilder : IStatementBuilder
- Inheritance
-
QueryBuilder
- Implements
- Inherited Members
Constructors
QueryBuilder(IQueryGenerator, List<QueryParameter>)
Initializes a new instance of the QueryBuilder class.
public QueryBuilder(IQueryGenerator queryGenerator, List<QueryParameter> parameters)
Parameters
queryGenerator
IQueryGeneratorThe IQueryGenerator used to generate SQL expressions and statements.
parameters
List<QueryParameter>The initial list of QueryParameter objects for the query.
Exceptions
- ArgumentNullException
Thrown if
queryGenerator
orparameters
isnull
.
Properties
Parameters
Gets the list of QueryParameter objects used in the query.
protected List<QueryParameter> Parameters { get; }
Property Value
- List<QueryParameter>
The list of query parameters.
QueryGenerator
Gets the IQueryGenerator used to generate SQL expressions and statements.
protected IQueryGenerator QueryGenerator { get; }
Property Value
- IQueryGenerator
The IQueryGenerator instance.
Methods
BuildStatement()
Builds and returns a QueryStatement representing the composed SQL query and its parameters.
public QueryStatement BuildStatement()
Returns
- QueryStatement
A QueryStatement containing the SQL statement and associated QueryParameter values.
Delete()
Starts a new DELETE statement builder and adds it to the query.
public DeleteBuilder Delete()
Returns
- DeleteBuilder
A new DeleteBuilder instance for building a DELETE statement.
Delete<TEntity>()
Starts a new DELETE statement builder for a specific entity type and adds it to the query.
public DeleteEntityBuilder<TEntity> Delete<TEntity>() where TEntity : class
Returns
- DeleteEntityBuilder<TEntity>
A new DeleteEntityBuilder<TEntity> instance for building a DELETE statement.
Type Parameters
TEntity
The type of the entity to delete.
Insert()
Starts a new INSERT statement builder and adds it to the query.
public InsertBuilder Insert()
Returns
- InsertBuilder
A new InsertBuilder instance for building an INSERT statement.
Insert<TEntity>()
Starts a new INSERT statement builder for a specific entity type and adds it to the query.
public InsertEntityBuilder<TEntity> Insert<TEntity>() where TEntity : class
Returns
- InsertEntityBuilder<TEntity>
A new InsertEntityBuilder<TEntity> instance for building an INSERT statement.
Type Parameters
TEntity
The type of the entity to insert.
Select()
Starts a new SELECT statement builder and adds it to the query.
public SelectBuilder Select()
Returns
- SelectBuilder
A new SelectBuilder instance for building a SELECT statement.
Select<TEntity>()
Starts a new SELECT statement builder for a specific entity type and adds it to the query.
public SelectEntityBuilder<TEntity> Select<TEntity>() where TEntity : class
Returns
- SelectEntityBuilder<TEntity>
A new SelectEntityBuilder<TEntity> instance for building a SELECT statement.
Type Parameters
TEntity
The type of the entity to select.
Statement()
Starts a new raw SQL statement builder and adds it to the query.
public StatementBuilder Statement()
Returns
- StatementBuilder
A new StatementBuilder instance for building a raw SQL statement.
Update()
Starts a new UPDATE statement builder and adds it to the query.
public UpdateBuilder Update()
Returns
- UpdateBuilder
A new UpdateBuilder instance for building an UPDATE statement.
Update<TEntity>()
Starts a new UPDATE statement builder for a specific entity type and adds it to the query.
public UpdateEntityBuilder<TEntity> Update<TEntity>() where TEntity : class
Returns
- UpdateEntityBuilder<TEntity>
A new UpdateEntityBuilder<TEntity> instance for building an UPDATE statement.
Type Parameters
TEntity
The type of the entity to update.