Class ExpressionSpecBase<TModel, TMetadata>
- Namespace
- Motiv
- Assembly
- Motiv.dll
The base class for propositions that retain a recoverable predicate expression tree. Composing instances of this type (or ExpressionPolicyBase<TModel, TMetadata>) with the logical operators yields propositions that are themselves expression-backed, so the composed expression can be recovered via ToExpression() and used with query providers.
public abstract class ExpressionSpecBase<TModel, TMetadata> : SpecBase<TModel, TMetadata>, IExpressionSpec<TModel>
Type Parameters
TModelThe model type that the proposition evaluates against.
TMetadataThe type of the metadata associated with the proposition.
- Implements
-
IExpressionSpec<TModel>
- Inherited Members
- Extension Methods
Methods
And(ExpressionPolicyBase<TModel, TMetadata>)
Combines this proposition with another expression-backed proposition using the logical AND operator. The result is itself expression-backed.
public ExpressionSpecBase<TModel, TMetadata> And(ExpressionPolicyBase<TModel, TMetadata> spec)
Parameters
specExpressionPolicyBase<TModel, TMetadata>The expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical AND of the two propositions.
And(ExpressionSpecBase<TModel, TMetadata>)
Combines this proposition with another expression-backed proposition using the logical AND operator. The result is itself expression-backed.
public ExpressionSpecBase<TModel, TMetadata> And(ExpressionSpecBase<TModel, TMetadata> spec)
Parameters
specExpressionSpecBase<TModel, TMetadata>The expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical AND of the two propositions.
And(SpecBase<TModel, TMetadata>)
Combines this proposition with a same-metadata proposition that is not itself expression-backed, using the logical AND operator. Because the other operand's predicate cannot be recovered as an expression, the result degrades to an ordinary (non expression-backed) proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to And<TSpec>(TSpec), preserving overload resolution parity.
public SpecBase<TModel, TMetadata> And(SpecBase<TModel, TMetadata> spec)
Parameters
specSpecBase<TModel, TMetadata>The proposition to combine with this proposition.
Returns
- SpecBase<TModel, TMetadata>
An ordinary proposition representing the logical AND of the two propositions.
And(SpecBase<TModel>)
Combines this proposition with an ordinary proposition of a different metadata type, using the logical AND operator. Because neither operand's predicate can be recovered as an expression (the other operand isn't expression-backed), the result degrades to an ordinary explanation proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to And<TSpec>(TSpec), preserving overload resolution parity.
public SpecBase<TModel, string> And(SpecBase<TModel> spec)
Parameters
specSpecBase<TModel>The proposition to combine with this proposition.
Returns
- SpecBase<TModel, string>
An ordinary explanation proposition representing the logical AND of the two propositions.
AndAlso(ExpressionPolicyBase<TModel, TMetadata>)
Combines this proposition with another expression-backed proposition using the conditional AND
operator. The right operand is only evaluated if the left operand resolves to true, since a
false left operand means the AND operation cannot return true. This is commonly referred
to as "short-circuiting".
public ExpressionSpecBase<TModel, TMetadata> AndAlso(ExpressionPolicyBase<TModel, TMetadata> spec)
Parameters
specExpressionPolicyBase<TModel, TMetadata>The expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the conditional AND of the two propositions.
AndAlso(ExpressionSpecBase<TModel, TMetadata>)
Combines this proposition with another expression-backed proposition using the conditional AND
operator. The right operand is only evaluated if the left operand resolves to true, since a
false left operand means the AND operation cannot return true. This is commonly referred
to as "short-circuiting".
public ExpressionSpecBase<TModel, TMetadata> AndAlso(ExpressionSpecBase<TModel, TMetadata> spec)
Parameters
specExpressionSpecBase<TModel, TMetadata>The expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the conditional AND of the two propositions.
AndAlso(SpecBase<TModel, TMetadata>)
Combines this proposition with a same-metadata proposition that is not itself expression-backed, using the conditional AND operator. Because the other operand's predicate cannot be recovered as an expression, the result degrades to an ordinary (non expression-backed) proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to AndAlso<TSpec>(TSpec), preserving overload resolution parity.
public SpecBase<TModel, TMetadata> AndAlso(SpecBase<TModel, TMetadata> spec)
Parameters
specSpecBase<TModel, TMetadata>The proposition to combine with this proposition.
Returns
- SpecBase<TModel, TMetadata>
An ordinary proposition representing the conditional AND of the two propositions.
AndAlso(SpecBase<TModel>)
Combines this proposition with an ordinary proposition of a different metadata type, using the conditional AND operator. Because neither operand's predicate can be recovered as an expression (the other operand isn't expression-backed), the result degrades to an ordinary explanation proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to AndAlso<TSpec>(TSpec), preserving overload resolution parity.
public SpecBase<TModel, string> AndAlso(SpecBase<TModel> spec)
Parameters
specSpecBase<TModel>The proposition to combine with this proposition.
Returns
- SpecBase<TModel, string>
An ordinary explanation proposition representing the conditional AND of the two propositions.
AndAlso<TSpec>(TSpec)
Combines this proposition with an expression-backed proposition that has a different metadata
type, using the conditional AND operator. The right operand is only evaluated if the left operand
resolves to true. The operands are coerced to string metadata, and the result remains
expression-backed.
public ExpressionSpecBase<TModel, string> AndAlso<TSpec>(TSpec spec) where TSpec : SpecBase<TModel>, IExpressionSpec<TModel>
Parameters
specTSpecThe expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, string>
An expression-backed explanation proposition representing the conditional AND.
Type Parameters
TSpecThe type of the other proposition.
And<TSpec>(TSpec)
Combines this proposition with an expression-backed proposition that has a different metadata type, using the logical AND operator. The operands are coerced to string metadata, and the result remains expression-backed.
public ExpressionSpecBase<TModel, string> And<TSpec>(TSpec spec) where TSpec : SpecBase<TModel>, IExpressionSpec<TModel>
Parameters
specTSpecThe expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, string>
An expression-backed explanation proposition representing the logical AND.
Type Parameters
TSpecThe type of the other proposition.
Not()
Negates this proposition. The result is itself expression-backed.
public ExpressionSpecBase<TModel, TMetadata> Not()
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical NOT of this proposition.
Or(ExpressionPolicyBase<TModel, TMetadata>)
Combines this proposition with another expression-backed proposition using the logical OR operator.
Both operands will be evaluated, regardless of whether the left operand evaluated to true.
public ExpressionSpecBase<TModel, TMetadata> Or(ExpressionPolicyBase<TModel, TMetadata> spec)
Parameters
specExpressionPolicyBase<TModel, TMetadata>The expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical OR of the two propositions.
Or(ExpressionSpecBase<TModel, TMetadata>)
Combines this proposition with another expression-backed proposition using the logical OR operator.
Both operands will be evaluated, regardless of whether the left operand evaluated to true.
public ExpressionSpecBase<TModel, TMetadata> Or(ExpressionSpecBase<TModel, TMetadata> spec)
Parameters
specExpressionSpecBase<TModel, TMetadata>The expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical OR of the two propositions.
Or(SpecBase<TModel, TMetadata>)
Combines this proposition with a same-metadata proposition that is not itself expression-backed, using the logical OR operator. Because the other operand's predicate cannot be recovered as an expression, the result degrades to an ordinary (non expression-backed) proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to Or<TSpec>(TSpec), preserving overload resolution parity.
public SpecBase<TModel, TMetadata> Or(SpecBase<TModel, TMetadata> spec)
Parameters
specSpecBase<TModel, TMetadata>The proposition to combine with this proposition.
Returns
- SpecBase<TModel, TMetadata>
An ordinary proposition representing the logical OR of the two propositions.
Or(SpecBase<TModel>)
Combines this proposition with an ordinary proposition of a different metadata type, using the logical OR operator. Because neither operand's predicate can be recovered as an expression (the other operand isn't expression-backed), the result degrades to an ordinary explanation proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to Or<TSpec>(TSpec), preserving overload resolution parity.
public SpecBase<TModel, string> Or(SpecBase<TModel> spec)
Parameters
specSpecBase<TModel>The proposition to combine with this proposition.
Returns
- SpecBase<TModel, string>
An ordinary explanation proposition representing the logical OR of the two propositions.
OrElse(ExpressionPolicyBase<TModel, TMetadata>)
Combines this proposition with another expression-backed proposition using the conditional OR
operator. The right operand is only evaluated if the left operand resolves to false, since a
true left operand means the OR operation is already satisfied. This is commonly referred to as
"short-circuiting".
public ExpressionSpecBase<TModel, TMetadata> OrElse(ExpressionPolicyBase<TModel, TMetadata> spec)
Parameters
specExpressionPolicyBase<TModel, TMetadata>The expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the conditional OR of the two propositions.
OrElse(ExpressionSpecBase<TModel, TMetadata>)
Combines this proposition with another expression-backed proposition using the conditional OR
operator. The right operand is only evaluated if the left operand resolves to false, since a
true left operand means the OR operation is already satisfied. This is commonly referred to as
"short-circuiting".
public ExpressionSpecBase<TModel, TMetadata> OrElse(ExpressionSpecBase<TModel, TMetadata> spec)
Parameters
specExpressionSpecBase<TModel, TMetadata>The expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the conditional OR of the two propositions.
OrElse(SpecBase<TModel, TMetadata>)
Combines this proposition with a same-metadata proposition that is not itself expression-backed, using the conditional OR operator. Because the other operand's predicate cannot be recovered as an expression, the result degrades to an ordinary (non expression-backed) proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to OrElse<TSpec>(TSpec), preserving overload resolution parity.
public SpecBase<TModel, TMetadata> OrElse(SpecBase<TModel, TMetadata> spec)
Parameters
specSpecBase<TModel, TMetadata>The proposition to combine with this proposition.
Returns
- SpecBase<TModel, TMetadata>
An ordinary proposition representing the conditional OR of the two propositions.
OrElse(SpecBase<TModel>)
Combines this proposition with an ordinary proposition of a different metadata type, using the conditional OR operator. Because neither operand's predicate can be recovered as an expression (the other operand isn't expression-backed), the result degrades to an ordinary explanation proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to OrElse<TSpec>(TSpec), preserving overload resolution parity.
public SpecBase<TModel, string> OrElse(SpecBase<TModel> spec)
Parameters
specSpecBase<TModel>The proposition to combine with this proposition.
Returns
- SpecBase<TModel, string>
An ordinary explanation proposition representing the conditional OR of the two propositions.
OrElse<TSpec>(TSpec)
Combines this proposition with an expression-backed proposition that has a different metadata
type, using the conditional OR operator. The right operand is only evaluated if the left operand
resolves to false. The operands are coerced to string metadata, and the result remains
expression-backed.
public ExpressionSpecBase<TModel, string> OrElse<TSpec>(TSpec spec) where TSpec : SpecBase<TModel>, IExpressionSpec<TModel>
Parameters
specTSpecThe expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, string>
An expression-backed explanation proposition representing the conditional OR.
Type Parameters
TSpecThe type of the other proposition.
Or<TSpec>(TSpec)
Combines this proposition with an expression-backed proposition that has a different metadata type, using the logical OR operator. The operands are coerced to string metadata, and the result remains expression-backed.
public ExpressionSpecBase<TModel, string> Or<TSpec>(TSpec spec) where TSpec : SpecBase<TModel>, IExpressionSpec<TModel>
Parameters
specTSpecThe expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, string>
An expression-backed explanation proposition representing the logical OR.
Type Parameters
TSpecThe type of the other proposition.
ToExplanationSpec()
Converts this proposition to an explanation proposition (string metadata) while preserving the underlying predicate expression tree.
public override SpecBase<TModel, string> ToExplanationSpec()
Returns
ToExpression()
Gets the predicate expression tree that this proposition represents.
public abstract Expression<Func<TModel, bool>> ToExpression()
Returns
- Expression<Func<TModel, bool>>
The predicate lambda expression describing this proposition.
XOr(ExpressionPolicyBase<TModel, TMetadata>)
Combines this proposition with another expression-backed proposition using the logical XOR operator. Both operands are always evaluated.
public ExpressionSpecBase<TModel, TMetadata> XOr(ExpressionPolicyBase<TModel, TMetadata> spec)
Parameters
specExpressionPolicyBase<TModel, TMetadata>The expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical XOR of the two propositions.
XOr(ExpressionSpecBase<TModel, TMetadata>)
Combines this proposition with another expression-backed proposition using the logical XOR operator. Both operands are always evaluated.
public ExpressionSpecBase<TModel, TMetadata> XOr(ExpressionSpecBase<TModel, TMetadata> spec)
Parameters
specExpressionSpecBase<TModel, TMetadata>The expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical XOR of the two propositions.
XOr(SpecBase<TModel, TMetadata>)
Combines this proposition with a same-metadata proposition that is not itself expression-backed, using the logical XOR operator. Because the other operand's predicate cannot be recovered as an expression, the result degrades to an ordinary (non expression-backed) proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to XOr<TSpec>(TSpec), preserving overload resolution parity.
public SpecBase<TModel, TMetadata> XOr(SpecBase<TModel, TMetadata> spec)
Parameters
specSpecBase<TModel, TMetadata>The proposition to combine with this proposition.
Returns
- SpecBase<TModel, TMetadata>
An ordinary proposition representing the logical XOR of the two propositions.
XOr(SpecBase<TModel>)
Combines this proposition with an ordinary proposition of a different metadata type, using the logical XOR operator. Because neither operand's predicate can be recovered as an expression (the other operand isn't expression-backed), the result degrades to an ordinary explanation proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to XOr<TSpec>(TSpec), preserving overload resolution parity.
public SpecBase<TModel, string> XOr(SpecBase<TModel> spec)
Parameters
specSpecBase<TModel>The proposition to combine with this proposition.
Returns
- SpecBase<TModel, string>
An ordinary explanation proposition representing the logical XOR of the two propositions.
XOr<TSpec>(TSpec)
Combines this proposition with an expression-backed proposition that has a different metadata type, using the logical XOR operator. Both operands are always evaluated. The operands are coerced to string metadata, and the result remains expression-backed.
public ExpressionSpecBase<TModel, string> XOr<TSpec>(TSpec spec) where TSpec : SpecBase<TModel>, IExpressionSpec<TModel>
Parameters
specTSpecThe expression-backed proposition to combine with this proposition.
Returns
- ExpressionSpecBase<TModel, string>
An expression-backed explanation proposition representing the logical XOR.
Type Parameters
TSpecThe type of the other proposition.
Operators
operator &(ExpressionPolicyBase<TModel, TMetadata>, ExpressionSpecBase<TModel, TMetadata>)
Combines two expression-backed propositions using the logical AND operator.
public static ExpressionSpecBase<TModel, TMetadata> operator &(ExpressionPolicyBase<TModel, TMetadata> left, ExpressionSpecBase<TModel, TMetadata> right)
Parameters
leftExpressionPolicyBase<TModel, TMetadata>The left operand of the AND operation.
rightExpressionSpecBase<TModel, TMetadata>The right operand of the AND operation.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical AND of the two propositions.
operator &(ExpressionSpecBase<TModel, TMetadata>, ExpressionPolicyBase<TModel, TMetadata>)
Combines two expression-backed propositions using the logical AND operator.
public static ExpressionSpecBase<TModel, TMetadata> operator &(ExpressionSpecBase<TModel, TMetadata> left, ExpressionPolicyBase<TModel, TMetadata> right)
Parameters
leftExpressionSpecBase<TModel, TMetadata>The left operand of the AND operation.
rightExpressionPolicyBase<TModel, TMetadata>The right operand of the AND operation.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical AND of the two propositions.
operator &(ExpressionSpecBase<TModel, TMetadata>, ExpressionSpecBase<TModel, TMetadata>)
Combines two expression-backed propositions using the logical AND operator.
public static ExpressionSpecBase<TModel, TMetadata> operator &(ExpressionSpecBase<TModel, TMetadata> left, ExpressionSpecBase<TModel, TMetadata> right)
Parameters
leftExpressionSpecBase<TModel, TMetadata>The left operand of the AND operation.
rightExpressionSpecBase<TModel, TMetadata>The right operand of the AND operation.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical AND of the two propositions.
operator |(ExpressionPolicyBase<TModel, TMetadata>, ExpressionSpecBase<TModel, TMetadata>)
Combines two expression-backed propositions using the logical OR operator.
public static ExpressionSpecBase<TModel, TMetadata> operator |(ExpressionPolicyBase<TModel, TMetadata> left, ExpressionSpecBase<TModel, TMetadata> right)
Parameters
leftExpressionPolicyBase<TModel, TMetadata>The left operand of the OR operation.
rightExpressionSpecBase<TModel, TMetadata>The right operand of the OR operation.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical OR of the two propositions.
operator |(ExpressionSpecBase<TModel, TMetadata>, ExpressionPolicyBase<TModel, TMetadata>)
Combines two expression-backed propositions using the logical OR operator.
public static ExpressionSpecBase<TModel, TMetadata> operator |(ExpressionSpecBase<TModel, TMetadata> left, ExpressionPolicyBase<TModel, TMetadata> right)
Parameters
leftExpressionSpecBase<TModel, TMetadata>The left operand of the OR operation.
rightExpressionPolicyBase<TModel, TMetadata>The right operand of the OR operation.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical OR of the two propositions.
operator |(ExpressionSpecBase<TModel, TMetadata>, ExpressionSpecBase<TModel, TMetadata>)
Combines two expression-backed propositions using the logical OR operator.
public static ExpressionSpecBase<TModel, TMetadata> operator |(ExpressionSpecBase<TModel, TMetadata> left, ExpressionSpecBase<TModel, TMetadata> right)
Parameters
leftExpressionSpecBase<TModel, TMetadata>The left operand of the OR operation.
rightExpressionSpecBase<TModel, TMetadata>The right operand of the OR operation.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical OR of the two propositions.
operator ^(ExpressionPolicyBase<TModel, TMetadata>, ExpressionSpecBase<TModel, TMetadata>)
Combines two expression-backed propositions using the logical XOR operator.
public static ExpressionSpecBase<TModel, TMetadata> operator ^(ExpressionPolicyBase<TModel, TMetadata> left, ExpressionSpecBase<TModel, TMetadata> right)
Parameters
leftExpressionPolicyBase<TModel, TMetadata>The left operand of the XOR operation.
rightExpressionSpecBase<TModel, TMetadata>The right operand of the XOR operation.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical XOR of the two propositions.
operator ^(ExpressionSpecBase<TModel, TMetadata>, ExpressionPolicyBase<TModel, TMetadata>)
Combines two expression-backed propositions using the logical XOR operator.
public static ExpressionSpecBase<TModel, TMetadata> operator ^(ExpressionSpecBase<TModel, TMetadata> left, ExpressionPolicyBase<TModel, TMetadata> right)
Parameters
leftExpressionSpecBase<TModel, TMetadata>The left operand of the XOR operation.
rightExpressionPolicyBase<TModel, TMetadata>The right operand of the XOR operation.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical XOR of the two propositions.
operator ^(ExpressionSpecBase<TModel, TMetadata>, ExpressionSpecBase<TModel, TMetadata>)
Combines two expression-backed propositions using the logical XOR operator.
public static ExpressionSpecBase<TModel, TMetadata> operator ^(ExpressionSpecBase<TModel, TMetadata> left, ExpressionSpecBase<TModel, TMetadata> right)
Parameters
leftExpressionSpecBase<TModel, TMetadata>The left operand of the XOR operation.
rightExpressionSpecBase<TModel, TMetadata>The right operand of the XOR operation.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical XOR of the two propositions.
operator !(ExpressionSpecBase<TModel, TMetadata>)
Negates an expression-backed proposition.
public static ExpressionSpecBase<TModel, TMetadata> operator !(ExpressionSpecBase<TModel, TMetadata> spec)
Parameters
specExpressionSpecBase<TModel, TMetadata>The proposition to negate.
Returns
- ExpressionSpecBase<TModel, TMetadata>
An expression-backed proposition representing the logical NOT of the proposition.