using System; using System.Linq.Expressions; namespace Abp.Specifications { /// /// Represents the base class for specifications. /// /// The type of the object to which the specification is applied. public abstract class Specification : ISpecification { /// /// Returns a value which indicates whether the specification /// is satisfied by the given object. /// /// The object to which the specification is applied. /// True if the specification is satisfied, otherwise false. public virtual bool IsSatisfiedBy(T obj) { return ToExpression().Compile()(obj); } /// /// Gets the LINQ expression which represents the current specification. /// /// The LINQ expression. public abstract Expression> ToExpression(); /// /// Implicitly converts a specification to expression. /// /// public static implicit operator Expression>(Specification specification) { return specification.ToExpression(); } } }