예제 #1
0
        public override IEnumerable <object> GetFilteredRows(TemplateParameters p, FilterOperation?operation, string stringValue)
        {
            if (operation == null)
            {
                var column = p.Columns[ParsedToken.QueryToken];

                var filtered = p.Rows.Where(r => ToBool(r[column])).ToList();

                return(filtered);
            }
            else
            {
                var type = this.Type;

                object val = FilterValueConverter.Parse(stringValue, type, operation.Value.IsList());

                Expression value = Expression.Constant(val, type);

                ResultColumn col = p.Columns[ParsedToken.QueryToken];

                var expression = Signum.Utilities.ExpressionTrees.Linq.Expr((ResultRow rr) => rr[col]);

                Expression newBody = QueryUtils.GetCompareExpression(operation.Value, Expression.Convert(expression.Body, type), value, inMemory: true);
                var        lambda  = Expression.Lambda <Func <ResultRow, bool> >(newBody, expression.Parameters).Compile();

                var filtered = p.Rows.Where(lambda).ToList();

                return(filtered);
            }
        }
예제 #2
0
        public bool GetCondition(TemplateParameters p, FilterOperation?operation, string valueString)
        {
            var obj = this.GetValue(p);

            if (operation == null)
            {
                return(ToBool(obj));
            }
            else
            {
                var type = this.Type;

                Expression token = Expression.Constant(obj, type);

                Expression value = Expression.Constant(FilterValueConverter.Parse(valueString, type, operation.Value.IsList()), type);

                Expression newBody = QueryUtils.GetCompareExpression(operation.Value, token, value, inMemory: true);
                var        lambda  = Expression.Lambda <Func <bool> >(newBody).Compile();

                return(lambda());
            }
        }
예제 #3
0
        public override bool Evaluate(TemplateParameters p)
        {
            var obj = ValueProvider !.GetValue(p);

            if (Operation == null)
            {
                return(ToBool(obj));
            }
            else
            {
                var type = this.ValueProvider.Type !;

                Expression token = Expression.Constant(obj, type);

                Expression value = Expression.Constant(FilterValueConverter.Parse(Value, type, Operation.Value.IsList()), type);

                Expression newBody = QueryUtils.GetCompareExpression(Operation.Value, token, value, inMemory: true);
                var        lambda  = Expression.Lambda <Func <bool> >(newBody).Compile();

                return(lambda());
            }
        }