using System;
using System.Linq.Expressions;
namespace Abp.Specifications
{
///
/// Represents the specification which indicates the semantics opposite to the given specification.
///
/// The type of the object to which the specification is applied.
public class NotSpecification : Specification
{
private readonly ISpecification _specification;
///
/// Initializes a new instance of class.
///
/// The specification to be reversed.
public NotSpecification(ISpecification specification)
{
_specification = specification;
}
///
/// Gets the LINQ expression which represents the current specification.
///
/// The LINQ expression.
public override Expression> ToExpression()
{
var expression = _specification.ToExpression();
return Expression.Lambda>(
Expression.Not(expression.Body),
expression.Parameters
);
}
}
}