protected virtual List <Customer> ExecuteQuery(LogicalRuleOperator logicalOperator, params FilterExpression[] expressions) { var compositeFilter = new FilterExpressionGroup(typeof(Customer)) { LogicalOperator = logicalOperator }; compositeFilter.AddExpressions(expressions); var predicate = compositeFilter.ToPredicate(true); var result = _customers.AsQueryable().Where(predicate).Cast <Customer>().ToList(); return(result); }
public IPagedList <Customer> ProcessFilter( FilterExpression[] filters, LogicalRuleOperator logicalOperator, int pageIndex = 0, int pageSize = int.MaxValue) { Guard.NotNull(filters, nameof(filters)); if (filters.Length == 0) { return(new PagedList <Customer>(Enumerable.Empty <Customer>(), 0, int.MaxValue)); } // TODO: really untracked? var query = _rsCustomer.TableUntracked.Where(x => !x.Deleted); FilterExpressionGroup group = null; if (filters.Length == 1 && filters[0] is FilterExpressionGroup group2) { group = group2; } else { group = new FilterExpressionGroup(typeof(Customer)) { LogicalOperator = logicalOperator }; group.AddExpressions(filters); } // Create lambda predicate var predicate = group.ToPredicate(false); // Apply predicate to query query = query .Where(predicate) .Cast <Customer>() .OrderByDescending(c => c.CreatedOnUtc); return(new PagedList <Customer>(query, pageIndex, pageSize)); }