Class Predicates
谓词组工具方法
Inheritance
Namespace: DapperDal.Predicate
Assembly: DapperDal.dll
Syntax
public static class Predicates : object
Methods
| Improve this Doc View SourceBetween<T>(Expression<Func<T, Object>>, BetweenValues, Boolean)
Factory method that creates a new IBetweenPredicate predicate.
Declaration
public static IBetweenPredicate Between<T>(Expression<Func<T, object>> expression, BetweenValues values, bool not = false)where T : class
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<T, System.Object>> | expression | |
| BetweenValues | values | |
| System.Boolean | not |
Returns
| Type | Description |
|---|---|
| IBetweenPredicate |
Type Parameters
| Name | Description |
|---|---|
| T |
Exists<TSub>(IPredicate, Boolean)
Factory method that creates a new IExistsPredicate predicate.
Declaration
public static IExistsPredicate Exists<TSub>(IPredicate predicate, bool not = false)where TSub : class
Parameters
| Type | Name | Description |
|---|---|---|
| IPredicate | predicate | |
| System.Boolean | not |
Returns
| Type | Description |
|---|---|
| IExistsPredicate |
Type Parameters
| Name | Description |
|---|---|
| TSub |
Field<T>(Expression<Func<T, Object>>, Operator, Object, Boolean)
Factory method that creates a new IFieldPredicate predicate: [FieldName] [Operator] [Value]. Example: WHERE FirstName = 'Foo'
Declaration
public static IFieldPredicate Field<T>(Expression<Func<T, object>> expression, Operator op, object value, bool not = false)where T : class
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<T, System.Object>> | expression | An expression that returns the left operand [FieldName]. |
| Operator | op | The comparison operator. |
| System.Object | value | The value for the predicate. |
| System.Boolean | not | Effectively inverts the comparison operator. Example: WHERE FirstName <> 'Foo'. |
Returns
| Type | Description |
|---|---|
| IFieldPredicate | An instance of IFieldPredicate. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the entity. |
Group(GroupOperator, IPredicate[])
Factory method that creates a new IPredicateGroup predicate. Predicate groups can be joined together with other predicate groups.
Declaration
public static IPredicateGroup Group(GroupOperator op, params IPredicate[] predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| GroupOperator | op | The grouping operator to use when joining the predicates (AND / OR). |
| IPredicate[] | predicate | A list of predicates to group. |
Returns
| Type | Description |
|---|---|
| IPredicateGroup | An instance of IPredicateGroup. |
Property<T, T2>(Expression<Func<T, Object>>, Operator, Expression<Func<T2, Object>>, Boolean)
Factory method that creates a new IPropertyPredicate predicate: [FieldName1] [Operator] [FieldName2] Example: WHERE FirstName = LastName
Declaration
public static IPropertyPredicate Property<T, T2>(Expression<Func<T, object>> expression, Operator op, Expression<Func<T2, object>> expression2, bool not = false)where T : class where T2 : class
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<T, System.Object>> | expression | An expression that returns the left operand [FieldName1]. |
| Operator | op | The comparison operator. |
| Expression<Func<T2, System.Object>> | expression2 | An expression that returns the right operand [FieldName2]. |
| System.Boolean | not | Effectively inverts the comparison operator. Example: WHERE FirstName <> LastName |
Returns
| Type | Description |
|---|---|
| IPropertyPredicate | An instance of IPropertyPredicate. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the entity for the left operand. |
| T2 | The type of the entity for the right operand. |
Sort<T>(Expression<Func<T, Object>>, Boolean)
Factory method that creates a new Sort which controls how the results will be sorted.
Declaration
public static ISort Sort<T>(Expression<Func<T, object>> expression, bool ascending = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<T, System.Object>> | expression | |
| System.Boolean | ascending |
Returns
| Type | Description |
|---|---|
| ISort |
Type Parameters
| Name | Description |
|---|---|
| T |