AndSpecification.cs 1.1 KB

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Linq.Expressions;
  3. namespace Abp.Specifications
  4. {
  5. /// <summary>
  6. /// Represents the combined specification which indicates that both of the given
  7. /// specifications should be satisfied by the given object.
  8. /// </summary>
  9. /// <typeparam name="T">The type of the object to which the specification is applied.</typeparam>
  10. public class AndSpecification<T> : CompositeSpecification<T>
  11. {
  12. /// <summary>
  13. /// Constructs a new instance of <see cref="AndSpecification{T}"/> class.
  14. /// </summary>
  15. /// <param name="left">The first specification.</param>
  16. /// <param name="right">The second specification.</param>
  17. public AndSpecification(ISpecification<T> left, ISpecification<T> right) : base(left, right) { }
  18. /// <summary>
  19. /// Gets the LINQ expression which represents the current specification.
  20. /// </summary>
  21. /// <returns>The LINQ expression.</returns>
  22. public override Expression<Func<T, bool>> ToExpression()
  23. {
  24. return Left.ToExpression().And(Right.ToExpression());
  25. }
  26. }
  27. }