Пример #1
0
        public static IEnumerable <RewriteRule> AtomInvokeParam(SqlExprParams pars)
        {
            var invokeRule = RewriteRule.Create(
                "atomInvokeParam",
                () => RewriteSpecial.Call <RewriteTypes.C2>(null, "Invoke"),
                null,
                null,
                (match, expr, visit) =>
            {
                var exprCall = (MethodCallExpression)expr;
                var origArgs = exprCall.Arguments;

                //Aplicar la transformación del from a los parametros, esto es importante porque el from
                //en algunos casos se usa sólo para especificar el tipo en un método generico pero su valor
                //no es importante.
                var fromArgs = origArgs
                               .Select(x => Rewriter.RecApplyRules(x, ExprParamsRules(pars), ExcludeFromRewrite))
                               .ToList()
                ;

                var arg  = fromArgs[0];
                var args = fromArgs;

                var atomArg  = Expression.Call(typeof(RewriteSpecial), "Atom", new[] { arg.Type }, arg);
                var atomArgs = new[] { atomArg }.Concat(args.Skip(1)).ToList();



                var retCall = Expression.Call(exprCall.Object, exprCall.Method, atomArgs);
                return(retCall);
            });

            return(new[] { invokeRule });
        }
Пример #2
0
        public override Expression Visit(Expression node)
        {
            var ret = node;

            foreach (var ruleSet in rules)
            {
                var old  = ret;
                var next = Rewriter.RecApplyRules(old, ruleSet, SqlFunctions.ExcludeFromRewrite);
                ret = next;
            }
            return(ret);
        }
Пример #3
0
        public static Expression VisitFromItem(Expression expr)
        {
            var ret = Rewriter.RecApplyRules(expr, new[] { DefaultRewrite.InvokeRule(null) }, x => false);

            return(ret);
        }
Пример #4
0
        /// <summary>
        /// Aplica recursivamente cierto conjunto de reglas a todo el arbol de expresión
        /// </summary>
        static Expression ApplyRules(Expression expr, IEnumerable <RewriteRule> rules)
        {
            var ret = Rewriter.RecApplyRules(expr, rules, SqlFunctions.ExcludeFromRewrite);

            return(ret);
        }