Class PredicateBuilder
谓词表达式构建扩展方法
Inheritance
Namespace: DapperDal.Expressions
Assembly: DapperDal.dll
Syntax
public static class PredicateBuilder : object
Methods
| Improve this Doc View SourceAll<T>(Expression<Func<T, Boolean>>[])
Performs a reduction on the given list of predicates using logical "and". Returns a True<T>() expression if the list is empty
Declaration
public static Expression<Func<T, bool>> All<T>(params Expression<Func<T, bool>>[] predicates)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T, System.Boolean>>[] | predicates | The predicates |
Returns
Type | Description |
---|---|
Expression<Func<T, System.Boolean>> | A series of "and" expressions |
Type Parameters
Name | Description |
---|---|
T | The input type for all predicates |
All<T>(IEnumerable<Expression<Func<T, Boolean>>>)
Performs a reduction on the given list of predicates using logical "and". Returns a True<T>() expression if the list is empty
Declaration
public static Expression<Func<T, bool>> All<T>(this IEnumerable<Expression<Func<T, bool>>> predicates)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Expression<Func<T, System.Boolean>>> | predicates | The predicates |
Returns
Type | Description |
---|---|
Expression<Func<T, System.Boolean>> | A series of "and" expressions |
Type Parameters
Name | Description |
---|---|
T | The input type for all predicates |
And<T>(Expression<Func<T, Boolean>>, Expression<Func<T, Boolean>>)
Combines the first predicate with the second using a logical "and". Short-circuits if either expression is constant
Declaration
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T, System.Boolean>> | first | The first predicate |
Expression<Func<T, System.Boolean>> | second | The second predicate |
Returns
Type | Description |
---|---|
Expression<Func<T, System.Boolean>> | An expression representing a logical "and" between both predicates |
Type Parameters
Name | Description |
---|---|
T | The input type for both predicates |
Any<T>(Expression<Func<T, Boolean>>[])
Performs a reduction on the given list of predicates using logical "or". Returns a False<T>() expression if the list is empty
Declaration
public static Expression<Func<T, bool>> Any<T>(params Expression<Func<T, bool>>[] predicates)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T, System.Boolean>>[] | predicates | The predicates |
Returns
Type | Description |
---|---|
Expression<Func<T, System.Boolean>> | A series of "or" expressions |
Type Parameters
Name | Description |
---|---|
T | The input type for all predicates |
Any<T>(IEnumerable<Expression<Func<T, Boolean>>>)
Performs a reduction on the given list of predicates using logical "or". Returns a False<T>() expression if the list is empty
Declaration
public static Expression<Func<T, bool>> Any<T>(this IEnumerable<Expression<Func<T, bool>>> predicates)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Expression<Func<T, System.Boolean>>> | predicates | The predicates |
Returns
Type | Description |
---|---|
Expression<Func<T, System.Boolean>> | A series of "or" expressions |
Type Parameters
Name | Description |
---|---|
T | The input type for all predicates |
False<T>()
Produces a predicate expression always returning false
Declaration
public static Expression<Func<T, bool>> False<T>()
Returns
Type | Description |
---|---|
Expression<Func<T, System.Boolean>> | A constant expression returning false |
Type Parameters
Name | Description |
---|---|
T | The input type for the resulting expression |
Not<T>(Expression<Func<T, Boolean>>)
Composes a negation with the result of the predicate
Declaration
public static Expression<Func<T, bool>> Not<T>(this Expression<Func<T, bool>> expr)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T, System.Boolean>> | expr | The predicate |
Returns
Type | Description |
---|---|
Expression<Func<T, System.Boolean>> | An expression negating the result of the predicate |
Type Parameters
Name | Description |
---|---|
T | The input type for the predicate |
Or<T>(Expression<Func<T, Boolean>>, Expression<Func<T, Boolean>>)
Combines the first predicate with the second using a logical "or". Short-circuits if either expression is constant
Declaration
public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T, System.Boolean>> | first | The first predicate |
Expression<Func<T, System.Boolean>> | second | The second predicate |
Returns
Type | Description |
---|---|
Expression<Func<T, System.Boolean>> | An expression representing a logical "or" between both predicates |
Type Parameters
Name | Description |
---|---|
T | The input type for both predicates |
True<T>()
Produces a predicate expression always returning true
Declaration
public static Expression<Func<T, bool>> True<T>()
Returns
Type | Description |
---|---|
Expression<Func<T, System.Boolean>> | A constant expression returning true |
Type Parameters
Name | Description |
---|---|
T | The input type for the resulting expression |