private IQueryable <TEntity> ApplyFilter(IQueryable <TEntity> queryable, FilterDescriptor filterObject) { if (filterObject != null && filterObject.Filters.Count > 0) { var filters = filterObject.All().ToList(); var values = filters.Select(f => f.Value).ToArray(); string predicate = string.Empty; try { predicate = filterObject.ToExpression <TDto>(filters, MapFieldFromDTOtoEntity); } catch (Exception ex) { Console.WriteLine(ex.Message); return(queryable); } // Use the Where method of Dynamic Linq to filter the data queryable = queryable.Where(predicate, values); } return(queryable); }