Class LogicalEntityBuilder<TEntity>
- Namespace
- FluentCommand.Query
- Assembly
- FluentCommand.dll
Provides a builder for constructing logical SQL query expressions (such as grouped AND/OR conditions) for a specific entity type with fluent, chainable methods.
public class LogicalEntityBuilder<TEntity> : LogicalBuilder<LogicalEntityBuilder<TEntity>>, IStatementBuilder, IQueryBuilder, IWhereEntityBuilder<TEntity, LogicalEntityBuilder<TEntity>> where TEntity : class
Type Parameters
TEntity
The type of the entity.
- Inheritance
-
StatementBuilder<LogicalEntityBuilder<TEntity>>WhereBuilder<LogicalEntityBuilder<TEntity>>LogicalBuilder<LogicalEntityBuilder<TEntity>>LogicalEntityBuilder<TEntity>
- Implements
-
IWhereEntityBuilder<TEntity, LogicalEntityBuilder<TEntity>>
- Inherited Members
Constructors
LogicalEntityBuilder(IQueryGenerator, List<QueryParameter>, LogicalOperators)
Initializes a new instance of the LogicalEntityBuilder<TEntity> class.
public LogicalEntityBuilder(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
WhereAnd(Action<LogicalEntityBuilder<TEntity>>)
Adds a logical AND group to the WHERE clause using the specified builder action.
public LogicalEntityBuilder<TEntity> WhereAnd(Action<LogicalEntityBuilder<TEntity>> builder)
Parameters
builder
Action<LogicalEntityBuilder<TEntity>>An action that configures the logical AND group using a LogicalEntityBuilder<TEntity>.
Returns
- LogicalEntityBuilder<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 LogicalEntityBuilder<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
- LogicalEntityBuilder<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 LogicalEntityBuilder<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
- LogicalEntityBuilder<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 LogicalEntityBuilder<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
- LogicalEntityBuilder<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 LogicalEntityBuilder<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
- LogicalEntityBuilder<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 LogicalEntityBuilder<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
- LogicalEntityBuilder<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 LogicalEntityBuilder<TEntity> WhereOr(Action<LogicalEntityBuilder<TEntity>> builder)
Parameters
builder
Action<LogicalEntityBuilder<TEntity>>An action that configures the logical OR group using a LogicalEntityBuilder<TEntity>.
Returns
- LogicalEntityBuilder<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 LogicalEntityBuilder<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
- LogicalEntityBuilder<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 LogicalEntityBuilder<TEntity> Where<TValue>(Expression<Func<TEntity, TValue>> property, TValue parameterValue, string tableAlias, FilterOperators whereOperator = 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.
whereOperator
FilterOperatorsThe filter operator to use (default is Equal).
Returns
- LogicalEntityBuilder<TEntity>
The same builder instance for method chaining.
Type Parameters
TValue
The type of the value to compare.