If we have a complex dynamic search, we will usually create a SearchParameter object and then pass it to a method that will build our criteria for us.
For example, if we were looking for a person, we could have a search object that looks like this:
public class PersonSearchParameters { public string FirstName {get; set;} public string LastName {get; set;} public ICriteria GetSearchCriteria() { DetachedCriteria query = DetachedCriteria.For(typeof (Person));
Then for each type of search we can create a single criterion from the class or we will have a diverse search for parameter classes and their combination
source share