To know more about predicate delegate visit Predicate Delegate
How To Implement Predicate Builder
In this example, I have created an instance of PredicateBuilder with PatientInfo Model and add multiple OR and AND Condition based on their value. Predicate Builder automatically creates a dynamic query with Linq and combined into one Expression.
When We have a grid which filters record based on applied filter and filter parameter is in large number decision of use Dynamic LINQ result very high performance and minimize code writing while implementation otherwise it requires a number of if else statement based on filter parameter.
In the above code, I have used entity framework Entity function which is very useful when we have to perform DateTime operation. It is internally worked as SQL DateTime function.
Above Predicate builder helper method reference from albahari and from StackOverflow article and learn how powerful feature it is. predicate builder also works with IEnumerable and IQueryable.