protected IQueryable <T> FilterTypes(IQueryable <T> source) { IEnumerable <ProductItemType> selectedTypeValues = ProductItemType.Where(type => type.Value).ToDictionary(pair => pair.Key, pair => pair.Value).Keys; if (selectedTypeValues.Any()) { source = source.Where(p => selectedTypeValues.Contains(p.ProductItemType)); } return(source); }