Ejemplo n.º 1
0
        public Expression <Func <TEntity, bool> > BuildExpression(FilterRequest filterRequest, Dictionary <string, string> filterMaps)
        {
            // If no sortby field is supplied, use the default.
            if (filterRequest == null)
            {
                return(null);
            }

            var filter = new Builder.Filter <TEntity>();

            foreach (var filterDetail in filterRequest.Filters)
            {
                // For multi-values filter
                FilterStatementConnector connectLogic = filterRequest.Logic == "or" ? FilterStatementConnector.Or : FilterStatementConnector.And;
                if (filterDetail.Field == "Deleted")
                {
                    connectLogic = FilterStatementConnector.And;
                }

                filter.By(filterDetail.Field, this.OperationDictionary[filterDetail.Operator], filterDetail.Value, connectLogic);
            }

            return(filter.BuildExpression());
        }
Ejemplo n.º 2
0
 public Filter(FilterRequest filterRequest, Dictionary <string, string> filterMaps = null)
 {
     Expression = BuildExpression(filterRequest, filterMaps);
 }