I have a interface (client) with multiples filters, per e.j:
- Search by Code
- Search by Name
- Search by Last Name
- Search by ....
In these cases, I look with always the need of create a new Criteria object, per e.j.:
A form of solution maybe create a class with this filters:
public class Filters
This class may put in the constructor of any Criteria Object. But the problem is the same, I need always of conditionals, p.e.:
Filters.Code = Foo.Code;
This same problem repeat been in the moment to fetch in the DataPortal:
data = targetRepository.FetchByCode(Filters.Code);
data = targetRepository.FetchByName(Filters.Name);
The questions is:
Exists any pattern for Criterias, similar to Specifications in DDD, I understand with CSLA .NET is not a ORM, but I think the conditionals in CSLA framework to Criterias Objects is a little problem.
Can you help me with any pattern?
P.D.: I use IoC and DI with Unity, also use Managed Extensibility Framework (MEF) with CSLA .NET to apply polymorphism, but my problem is when I need apply this concepts with the Criteria Objects.
Maybe an option:
public interface IDynamicList<T>
List<T> FindAllByCriteria(string criteria);
List<T> FindAllByCriteria(Func<T, bool> criteria);
public class CustomerMock : ICustomerRepository
public List<Dto.CustomerDto> FindAllByCriteria(Func<Dto.CustomerDto, bool> criteria)
throw new NotImplementedException();
Copyright (c) Marimer LLC