Class DeleteEntityBuilder<TEntity>
- Namespace
- FluentCommand.Query
- Assembly
- FluentCommand.dll
Provides a builder for constructing SQL DELETE statements for a specific entity type with fluent, chainable methods.
public class DeleteEntityBuilder<TEntity> : DeleteBuilder<DeleteEntityBuilder<TEntity>>, IStatementBuilder, IQueryBuilder, IWhereEntityBuilder<TEntity, DeleteEntityBuilder<TEntity>> where TEntity : class
Type Parameters
TEntity
The type of the entity.
- Inheritance
-
StatementBuilder<DeleteEntityBuilder<TEntity>>WhereBuilder<DeleteEntityBuilder<TEntity>>DeleteBuilder<DeleteEntityBuilder<TEntity>>DeleteEntityBuilder<TEntity>
- Implements
-
IWhereEntityBuilder<TEntity, DeleteEntityBuilder<TEntity>>
- Inherited Members
Constructors
DeleteEntityBuilder(IQueryGenerator, List<QueryParameter>, LogicalOperators)
Initializes a new instance of the DeleteEntityBuilder<TEntity> class.
public DeleteEntityBuilder(IQueryGenerator queryGenerator, List<QueryParameter> parameters, LogicalOperators logicalOperator = LogicalOperators.And)
Parameters
queryGenerator
IQueryGeneratorThe IQueryGenerator used to generate SQL expressions.
parameters
List<QueryParameter>The list of QueryParameter objects for the query.
logicalOperator
LogicalOperatorsThe logical operator (LogicalOperators) to combine WHERE expressions. Defaults to And.
Methods
BuildStatement()
Builds the SQL DELETE statement using the current configuration.
public override QueryStatement BuildStatement()
Returns
- QueryStatement
A QueryStatement containing the SQL DELETE statement and its parameters.
From(string, string, string)
Sets the target table for the DELETE statement using the entity's mapping information by default.
public override DeleteEntityBuilder<TEntity> From(string tableName = null, string tableSchema = null, string tableAlias = null)
Parameters
tableName
stringThe name of the table (optional, defaults to entity mapping).
tableSchema
stringThe schema of the table (optional, defaults to entity mapping).
tableAlias
stringThe alias for the table (optional).
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Join<TRight>(Action<JoinEntityBuilder<TEntity, TRight>>)
Adds a JOIN clause to the DELETE statement using the specified builder action for the right entity.
public DeleteEntityBuilder<TEntity> Join<TRight>(Action<JoinEntityBuilder<TEntity, TRight>> builder) where TRight : class
Parameters
builder
Action<JoinEntityBuilder<TEntity, TRight>>An action that configures the join using a JoinEntityBuilder<TLeft, TRight>.
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TRight
The type of the right join entity.
Join<TLeft, TRight>(Action<JoinEntityBuilder<TLeft, TRight>>)
Adds a JOIN clause to the DELETE statement using the specified builder action for the left and right entities.
public DeleteEntityBuilder<TEntity> Join<TLeft, TRight>(Action<JoinEntityBuilder<TLeft, TRight>> builder) where TLeft : class where TRight : class
Parameters
builder
Action<JoinEntityBuilder<TLeft, TRight>>An action that configures the join using a JoinEntityBuilder<TLeft, TRight>.
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TLeft
The type of the left join entity.
TRight
The type of the right join entity.
OutputIf<TValue>(Expression<Func<TEntity, TValue>>, string, string, Func<string, bool>)
Conditionally adds an OUTPUT clause for the specified entity property if the condition is met.
public DeleteEntityBuilder<TEntity> OutputIf<TValue>(Expression<Func<TEntity, TValue>> property, string tableAlias = null, string columnAlias = null, Func<string, bool> condition = null)
Parameters
property
Expression<Func<TEntity, TValue>>An expression selecting the property to output.
tableAlias
stringThe alias for the table (optional).
columnAlias
stringThe alias for the output column (optional).
condition
Func<string, bool>A function that determines whether to add the OUTPUT clause. If
null
, the clause is always added.
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TValue
The type of the property value.
Output<TValue>(Expression<Func<TEntity, TValue>>, string, string)
Adds an OUTPUT clause for the specified entity property.
public DeleteEntityBuilder<TEntity> Output<TValue>(Expression<Func<TEntity, TValue>> property, string tableAlias = null, string columnAlias = null)
Parameters
property
Expression<Func<TEntity, TValue>>An expression selecting the property to output.
tableAlias
stringThe alias for the table (optional).
columnAlias
stringThe alias for the output column (optional).
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TValue
The type of the property value.
WhereAnd(Action<LogicalEntityBuilder<TEntity>>)
Adds a logical AND group to the WHERE clause using the specified builder action.
public DeleteEntityBuilder<TEntity> WhereAnd(Action<LogicalEntityBuilder<TEntity>> builder)
Parameters
builder
Action<LogicalEntityBuilder<TEntity>>An action that configures the logical AND group using a LogicalEntityBuilder<TEntity>.
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
WhereIf<TValue>(Expression<Func<TEntity, TValue>>, TValue, FilterOperators, Func<string, TValue, bool>)
Conditionally adds a WHERE clause for the specified property, value, and filter operator.
public DeleteEntityBuilder<TEntity> WhereIf<TValue>(Expression<Func<TEntity, TValue>> property, TValue parameterValue, FilterOperators filterOperator = FilterOperators.Equal, Func<string, TValue, bool> condition = null)
Parameters
property
Expression<Func<TEntity, TValue>>An expression selecting the property to filter on.
parameterValue
TValueThe value to compare the property against.
filterOperator
FilterOperatorsThe filter operator to use (default is Equal).
condition
Func<string, TValue, bool>A function that determines whether to add the clause, based on the property name and value. If
null
, the clause is always added.
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TValue
The type of the value to compare.
WhereIf<TValue>(Expression<Func<TEntity, TValue>>, TValue, string, FilterOperators, Func<string, TValue, bool>)
Conditionally adds a WHERE clause for the specified property, value, filter operator, and table alias.
public DeleteEntityBuilder<TEntity> WhereIf<TValue>(Expression<Func<TEntity, TValue>> property, TValue parameterValue, string tableAlias, FilterOperators filterOperator = FilterOperators.Equal, Func<string, TValue, bool> condition = null)
Parameters
property
Expression<Func<TEntity, TValue>>An expression selecting the property to filter on.
parameterValue
TValueThe value to compare the property against.
tableAlias
stringThe table alias to use in the query.
filterOperator
FilterOperatorsThe filter operator to use (default is Equal).
condition
Func<string, TValue, bool>A function that determines whether to add the clause, based on the table alias and value. If
null
, the clause is always added.
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TValue
The type of the value to compare.
WhereInIf<TValue>(Expression<Func<TEntity, TValue>>, IEnumerable<TValue>, Func<string, IEnumerable<TValue>, bool>)
Conditionally adds a WHERE IN clause for the specified property and collection of values.
public DeleteEntityBuilder<TEntity> WhereInIf<TValue>(Expression<Func<TEntity, TValue>> property, IEnumerable<TValue> parameterValues, Func<string, IEnumerable<TValue>, bool> condition = null)
Parameters
property
Expression<Func<TEntity, TValue>>An expression selecting the property to filter on.
parameterValues
IEnumerable<TValue>The collection of values for the IN clause.
condition
Func<string, IEnumerable<TValue>, bool>A function that determines whether to add the clause, based on the property name and values. If
null
, the clause is always added.
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TValue
The type of the values to compare.
WhereInIf<TValue>(Expression<Func<TEntity, TValue>>, IEnumerable<TValue>, string, Func<string, IEnumerable<TValue>, bool>)
Conditionally adds a WHERE IN clause for the specified property, collection of values, and table alias.
public DeleteEntityBuilder<TEntity> WhereInIf<TValue>(Expression<Func<TEntity, TValue>> property, IEnumerable<TValue> parameterValues, string tableAlias, Func<string, IEnumerable<TValue>, bool> condition = null)
Parameters
property
Expression<Func<TEntity, TValue>>An expression selecting the property to filter on.
parameterValues
IEnumerable<TValue>The collection of values for the IN clause.
tableAlias
stringThe table alias to use in the query.
condition
Func<string, IEnumerable<TValue>, bool>A function that determines whether to add the clause, based on the table alias and values. If
null
, the clause is always added.
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TValue
The type of the values to compare.
WhereIn<TValue>(Expression<Func<TEntity, TValue>>, IEnumerable<TValue>, string)
Adds a WHERE IN clause for the specified property and collection of values, with an optional table alias.
public DeleteEntityBuilder<TEntity> WhereIn<TValue>(Expression<Func<TEntity, TValue>> property, IEnumerable<TValue> parameterValues, string tableAlias = null)
Parameters
property
Expression<Func<TEntity, TValue>>An expression selecting the property to filter on.
parameterValues
IEnumerable<TValue>The collection of values for the IN clause.
tableAlias
stringThe table alias to use in the query (optional).
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TValue
The type of the values to compare.
WhereOr(Action<LogicalEntityBuilder<TEntity>>)
Adds a logical OR group to the WHERE clause using the specified builder action.
public DeleteEntityBuilder<TEntity> WhereOr(Action<LogicalEntityBuilder<TEntity>> builder)
Parameters
builder
Action<LogicalEntityBuilder<TEntity>>An action that configures the logical OR group using a LogicalEntityBuilder<TEntity>.
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Where<TValue>(Expression<Func<TEntity, TValue>>, TValue, FilterOperators)
Adds a WHERE clause for the specified property, value, and filter operator.
public DeleteEntityBuilder<TEntity> Where<TValue>(Expression<Func<TEntity, TValue>> property, TValue parameterValue, FilterOperators filterOperator = FilterOperators.Equal)
Parameters
property
Expression<Func<TEntity, TValue>>An expression selecting the property to filter on.
parameterValue
TValueThe value to compare the property against.
filterOperator
FilterOperatorsThe filter operator to use (default is Equal).
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TValue
The type of the value to compare.
Where<TValue>(Expression<Func<TEntity, TValue>>, TValue, string, FilterOperators)
Adds a WHERE clause for the specified property, value, filter operator, and table alias.
public DeleteEntityBuilder<TEntity> Where<TValue>(Expression<Func<TEntity, TValue>> property, TValue parameterValue, string tableAlias, FilterOperators filterOperator = FilterOperators.Equal)
Parameters
property
Expression<Func<TEntity, TValue>>An expression selecting the property to filter on.
parameterValue
TValueThe value to compare the property against.
tableAlias
stringThe table alias to use in the query.
filterOperator
FilterOperatorsThe filter operator to use (default is Equal).
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TValue
The type of the value to compare.
Where<TModel, TValue>(Expression<Func<TModel, TValue>>, TValue, string, FilterOperators)
Adds a WHERE clause for the specified model property, value, filter operator, and table alias.
public DeleteEntityBuilder<TEntity> Where<TModel, TValue>(Expression<Func<TModel, TValue>> property, TValue parameterValue, string tableAlias, FilterOperators filterOperator = FilterOperators.Equal)
Parameters
property
Expression<Func<TModel, TValue>>An expression selecting the property to filter on.
parameterValue
TValueThe value to compare the property against.
tableAlias
stringThe table alias to use in the query.
filterOperator
FilterOperatorsThe filter operator to use (default is Equal).
Returns
- DeleteEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TModel
The type of the model.
TValue
The type of the value to compare.