How to combine conditions dynamically?
This question is an enhancement to the already answered question How to apply multiple filter conditions (simultaneously) on a list? In the above mentioned question we have a method that applied AND operator on all the specifications. This is achieved by using LINQ All operator on the specifications. public static List<Product> GetProductsUisngAndFilters(List<Product> productList, List<Specification<Product>> productSpecifications) { return productList.Where(p => productSpecifications.All(ps => ps.IsSatisfiedBy(p))).ToList(); } We need to create a new method (GetProductsUisngDynamicFilters)