PredicateBuilder

Classes > Nimblesite.Sql.Model > PredicateBuilder

PredicateBuilder enables dynamic construction of Expression trees for LINQ predicates. Allows combining multiple predicates using And/Or operations for complex filtering. Uses parameter rebinding to ensure proper SQL translation.

public static class PredicateBuilder

Methods

True<T>()

public static Expression<Func<T, bool>> True<T>()

Creates a predicate that always returns true (universal quantifier).

Returns: Boolean>> - Expression that always evaluates to true

False<T>()

public static Expression<Func<T, bool>> False<T>()

Creates a predicate that always returns false (empty set).

Returns: Boolean>> - Expression that always evaluates to false

Or<T>(Expression<Func<T, bool>>, Expression<Func<T, bool>>)

public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> expr1, Expression<Func<T, bool>> expr2)

Combines two predicates using logical OR operation.

Parameters:

Name Type Description
expr1 Boolean>> First predicate expression
expr2 Boolean>> Second predicate expression

Returns: Boolean>> - Combined expression using OR logic

And<T>(Expression<Func<T, bool>>, Expression<Func<T, bool>>)

public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> expr1, Expression<Func<T, bool>> expr2)

Combines two predicates using logical AND operation.

Parameters:

Name Type Description
expr1 Boolean>> First predicate expression
expr2 Boolean>> Second predicate expression

Returns: Boolean>> - Combined expression using AND logic

Not<T>(Expression<Func<T, bool>>)

public static Expression<Func<T, bool>> Not<T>(this Expression<Func<T, bool>> expr)

Negates a predicate using logical NOT operation.

Parameters:

Name Type Description
expr Boolean>> Predicate expression to negate

Returns: Boolean>> - Negated expression