In the example below persons are fetched based on a search of 'John London', this will return persons with the name 'John' AND city 'London' or vice versa.
// search string var search="John London"; // split in two criteria var needles = search.Split(' '); // create main predicate (AND) var pbMain = PredicateBuilder.TrueThe sub predicate can be extended by more OR predicates (e.g. PostalCode, Email, Country, etc), which enables a google-like search functionality.(); // dynamic add OR predicates foreach (var needle in needles) { // create sub predicate (OR) var pb = PredicateBuilder.False (); pb = pb.Or (p => p.Name.Contains(needle)); pb = pb.Or (p => p.Address.City.Contains(needle)); // add the sub predicate to the main predicate pbMain = pbMain.And (pb); } // pbMain contains "WHERE (NAME = 'John' OR CITY = 'John') AND (NAME = 'London' OR CITY = 'London')" // run the predicate against NHibernate.Linq Query var persons = Session.Query ().Where(pbMain).ToList();