public ISpecification<Person> GetAgeSpecifications(SpecificationLogic logic, int? minAge, int? maxAge)
        {
            var minAgeSpecification = new PersonFromAgeSpecification(minAge);
            var maxAgeSpecification = new PersonUntilAgeSpecification(maxAge);

            return getSpecificationByLogic(logic, minAgeSpecification, maxAgeSpecification);
        }
        public ISpecification<Person> GetNameAndJobSpecification(SpecificationLogic logic, string nameFragment, string jobFragment)
        {
            var nameSpecification = new PersonNameSpecification(nameFragment);
            var jobSpecification = new PersonJobTitleSpecification(jobFragment);

            return getSpecificationByLogic(logic, nameSpecification, jobSpecification);

        }
Пример #3
0
        public void And_AllSpecificationsArePersistenceAware_ShouldReturnPersistenceAwareSpecification()
        {
            //Assert
            var specification1 = new TestPersistenceAwareSpec <TestEntity>(x => x.A == 1);
            var specification2 = new TestPersistenceAwareSpec <TestEntity>(x => x.B == 2);

            //Act
            var combinedSpec = SpecificationLogic.And(specification1, specification2);

            //Assert
            Assert.That(combinedSpec, Is.AssignableTo <PersistenceAndSpecification <TestEntity> >());
        }
 private ISpecification<Person> getSpecificationByLogic(SpecificationLogic logic, ISpecification<Person> left, ISpecification<Person> right)
 {
     if (logic == SpecificationLogic.And)
     {
         return new AndSpecification<Person>(left, right);
     }
     else if (logic == SpecificationLogic.Or)
     {
         return new OrSpecification<Person>(left, right);
     }
     else
     {
         throw new InvalidOperationException("Query.Logic is in invalid state.");
     }
 }
Пример #5
0
 public static PersistenceAwareSpecification <TEntity> operator &(
     PersistenceAwareSpecification <TEntity> spec1,
     PersistenceAwareSpecification <TEntity> spec2)
 {
     return(SpecificationLogic.And(spec1, spec2));
 }
Пример #6
0
 public static Specification <TEntity> operator &(
     Specification <TEntity> spec1,
     Specification <TEntity> spec2)
 {
     return(SpecificationLogic.And(spec1, spec2));
 }