예제 #1
0
        public override SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
        {
            builder.Append(expression.FunctioName);
            builder.Append("(");

            if (expression.Arguments != null &&
                expression.Arguments.Length > 0)
            {
                var args = expression.Arguments;
                var argc = args.Length;

                for (int i = 0; i < argc; i++)
                {
                    Visit(args[i]);

                    if (i < argc - 1)
                    {
                        builder.Append(", ");
                    }
                }
            }

            builder.Append(")");

            return(expression);
        }
예제 #2
0
        public override SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
        {
            var invoke = new Invoke(expression.FunctioName, expression.Arguments);
            aggFunFound = invoke.IsAggregate(query);

            return base.VisitFunctionCall(expression);
        }
예제 #3
0
        //public override SqlExpression VisitConstant(SqlConstantExpression constant) {
        //	var value = constant.Value;
        //	if (value.IsNull)
        //		return constant;

        //	var obj = value.Value;
        //	if (obj is SqlQueryObject) {
        //		return EvaluateQueryPlan((SqlQueryObject) obj);
        //	}

        //	return base.VisitConstant(constant);
        //}

        //private SqlConstantExpression EvaluateQueryPlan(SqlQueryObject obj) {
        //	if (context.QueryContext == null)
        //		throw new ExpressionEvaluateException("A query context is required to evaluate a query.");

        //	try {
        //		var plan = obj.QueryPlan;
        //		var result = plan.Evaluate(context.QueryContext);

        //		return SqlExpression.Constant(new DataObject(new TabularType(), SqlTabular.From(result)));
        //	} catch (ExpressionEvaluateException) {
        //		throw;
        //	} catch (Exception ex) {
        //		throw new ExpressionEvaluateException("Could not evaluate a query.", ex);
        //	}
        //}

        public override SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
        {
            try {
                var               invoke           = new Invoke(expression.FunctioName, expression.Arguments);
                IRequest          request          = null;
                IVariableResolver variableResolver = null;
                IGroupResolver    groupResolver    = null;
                if (context != null)
                {
                    request          = context.Request;
                    variableResolver = context.VariableResolver;
                    groupResolver    = context.GroupResolver;
                }

                // TODO: if we don't have a return value (PROCEDURES) what should w return?
                var result = invoke.Execute(request, variableResolver, groupResolver);
                if (!result.HasReturnValue)
                {
                    return(SqlExpression.Constant(DataObject.Null()));
                }

                return(SqlExpression.Constant(result.ReturnValue));
            } catch (ExpressionEvaluateException) {
                throw;
            } catch (Exception ex) {
                throw new ExpressionEvaluateException(String.Format("Could not evaluate function expression '{0}' because of an error.", expression), ex);
            }
        }
예제 #4
0
        public override SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
        {
            var invoke = new Invoke(expression.FunctioName, expression.Arguments);

            aggFunFound = invoke.IsAggregate(query);

            return(base.VisitFunctionCall(expression));
        }
예제 #5
0
        public override SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
        {
            var invoke   = new Invoke(expression.FunctioName, expression.Arguments);
            var function = invoke.ResolveRoutine(query) as IFunction;

            if (function != null)
            {
                SetType(function.ReturnType(invoke, query, variableResolver));
            }

            return(base.VisitFunctionCall(expression));
        }
예제 #6
0
            public override SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
            {
                var args = expression.Arguments;
                foreach (var arg in args) {
                    columnNames.AddRange(arg.Value.DiscoverReferences());
                }

                return base.VisitFunctionCall(expression);
            }
예제 #7
0
        public override SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
        {
            var invoke = new Invoke(expression.FunctioName, expression.Arguments);
            var function = invoke.ResolveRoutine(queryContext) as IFunction;
            if (function != null)
                dataType = function.ReturnType(invoke, queryContext, variableResolver);

            return base.VisitFunctionCall(expression);
        }
예제 #8
0
 /// <summary>
 /// Visits the expression that calls the function defined.
 /// </summary>
 /// <param name="expression">The <see cref="SqlFunctionCallExpression"/> to visit.</param>
 /// <returns></returns>
 public virtual SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
 {
     var ags = VisitInvokeArgumentList(expression.Arguments);
     return SqlExpression.FunctionCall(expression.FunctioName, ags);
 }
예제 #9
0
 public override SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
 {
     return base.VisitFunctionCall(expression);
 }
        //public override SqlExpression VisitConstant(SqlConstantExpression constant) {
        //    var value = constant.Value;
        //    if (value.IsNull)
        //        return constant;
        //    var obj = value.Value;
        //    if (obj is SqlQueryObject) {
        //        return EvaluateQueryPlan((SqlQueryObject) obj);
        //    }
        //    return base.VisitConstant(constant);
        //}
        //private SqlConstantExpression EvaluateQueryPlan(SqlQueryObject obj) {
        //    if (context.QueryContext == null)
        //        throw new ExpressionEvaluateException("A query context is required to evaluate a query.");
        //    try {
        //        var plan = obj.QueryPlan;
        //        var result = plan.Evaluate(context.QueryContext);
        //        return SqlExpression.Constant(new DataObject(new TabularType(), SqlTabular.From(result)));
        //    } catch (ExpressionEvaluateException) {
        //        throw;
        //    } catch (Exception ex) {
        //        throw new ExpressionEvaluateException("Could not evaluate a query.", ex);
        //    }
        //}
        public override SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
        {
            try {
                var invoke = new Invoke(expression.FunctioName, expression.Arguments);
                IRequest request = null;
                IVariableResolver variableResolver = null;
                IGroupResolver groupResolver = null;
                if (context != null) {
                    request = context.Request;
                    variableResolver = context.VariableResolver;
                    groupResolver = context.GroupResolver;
                }

                // TODO: if we don't have a return value (PROCEDURES) what should w return?
                var result = invoke.Execute(request, variableResolver, groupResolver);
                if (!result.HasReturnValue)
                    return SqlExpression.Constant(DataObject.Null());

                return SqlExpression.Constant(result.ReturnValue);
            } catch (ExpressionEvaluateException) {
                throw;
            } catch (Exception ex) {
                throw new ExpressionEvaluateException(String.Format("Could not evaluate function expression '{0}' because of an error.", expression), ex);
            }
        }
        public override SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
        {
            builder.Append(expression.FunctioName);
            builder.Append("(");

            if (expression.Arguments != null &&
                expression.Arguments.Length > 0) {
                var args = expression.Arguments;
                var argc = args.Length;

                for (int i = 0; i < argc; i++) {
                    Visit(args[i]);

                    if (i < argc - 1)
                        builder.Append(", ");
                }
            }

            builder.Append(")");

            return expression;
        }
예제 #12
0
 public override SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
 {
     return(base.VisitFunctionCall(expression));
 }
예제 #13
0
        /// <summary>
        /// Visits the expression that calls the function defined.
        /// </summary>
        /// <param name="expression">The <see cref="SqlFunctionCallExpression"/> to visit.</param>
        /// <returns></returns>
        public virtual SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
        {
            var ags = VisitExpressionList(expression.Arguments);

            return(SqlExpression.FunctionCall(expression.FunctioName, ags));
        }