Execute() public method

public Execute ( ) : InvokeResult
return InvokeResult
 public static DataObject InvokeFunction(this IQueryContext context, Invoke invoke)
 {
     var result = invoke.Execute(context);
     return result.ReturnValue;
 }
Ejemplo n.º 2
0
            public InvokeResult Execute(InvokeContext context)
            {
                // Rewrite the function to the object initialization

                var sourceArgs = context.Arguments == null ? new InvokeArgument[1] : context.Arguments;
                var args = new InvokeArgument[sourceArgs.Length + 1];
                Array.Copy(sourceArgs, 0, args, 1, sourceArgs.Length);
                args[0] = new InvokeArgument(SqlExpression.Constant(FunctionInfo.RoutineName.FullName));

                var initFunction = context.Request.Access().ResolveObjectName(DbObjectType.Routine, ObjectName.Parse("SYSTEM.NEW_OBJECT"));
                if (initFunction == null)
                    throw new InvalidOperationException("The object initialization function was not defined.");

                var invoke = new Invoke(initFunction, args);
                return invoke.Execute(context.Request, context.VariableResolver, context.GroupResolver);
            }
        //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);
            }
        }
Ejemplo n.º 4
0
 public static DataObject InvokeFunction(this IQuery query, Invoke invoke)
 {
     var result = invoke.Execute(query);
     return result.ReturnValue;
 }
Ejemplo n.º 5
0
        public static DataObject InvokeFunction(this IQueryContext context, Invoke invoke)
        {
            var result = invoke.Execute(context);

            return(result.ReturnValue);
        }
Ejemplo n.º 6
0
        public static DataObject InvokeFunction(this IQuery query, Invoke invoke)
        {
            var result = invoke.Execute(query);

            return(result.ReturnValue);
        }