Пример #1
0
 protected override Field ExecuteRoutine(IBlock context)
 {
     using (var execContext = new ExecutionContext(context, Body)) {
         Body.Execute(execContext);
         return Field.Null();
     }
 }
Пример #2
0
        private ExecutionContext(ExecutionContext parent, IRequest request, SqlStatement statement)
        {
            if (request == null)
                throw new ArgumentNullException("request");

            Parent = parent;
            Request = request;
            Statement = statement;

            Assertions = new SecurityAssertionRegistrar(parent != null ? parent.Assertions : null);
            Actions = new SecurityActionRegistrar();
        }
Пример #3
0
        public override InvokeResult Execute(InvokeContext context)
        {
            using (var execContext = new ExecutionContext(context.Request, Body)) {
                Body.Execute(execContext);

                if (!execContext.HasResult)
                    throw new InvalidOperationException("The execution of the function has no returns");

                var result = execContext.Result;
                var returnType = ReturnType(context);

                if (returnType is TabularType)
                    return context.Result(result);

                if (result.RowCount == 0)
                    throw new InvalidOperationException("The execution of the function has no returns");

                var retunValue = result.GetValue(0, 0);
                return context.Result(retunValue);
            }
        }
        public static StatementResult[] ExecuteStatements(this IRequest request, IExpressionPreparer preparer,
                                                          params SqlStatement[] statements)
        {
            if (statements == null)
            {
                throw new ArgumentNullException("statements");
            }
            if (statements.Length == 0)
            {
                throw new ArgumentException("No statements provided for execution", "statements");
            }

            var results = new StatementResult[statements.Length];

            for (int i = 0; i < statements.Length; i++)
            {
                var statement = statements[i];

                var             context = new ExecutionContext(request, statement);
                StatementResult result;

                try {
                    var prepared = statement.Prepare(request, preparer);

                    if (prepared == null)
                    {
                        throw new InvalidOperationException(String.Format(
                                                                "The preparation of the statement '{0}' returned a null instance", statement.GetType()));
                    }

                    prepared.Execute(context);


                    if (context.HasResult)
                    {
                        var constraints = FindConstraintsFor(request, context.Result);

                        result = new StatementResult(context.Result, constraints);
                    }
                    else if (context.HasCursor)
                    {
                        // TODO: we should find a way to project the source info of the cursor without executing it
                        var constraints = FindConstraintsFor(request, context.Cursor.Source);
                        context.Cursor.Reset();
                        result = new StatementResult(context.Cursor, constraints);
                    }
                    else if (context.IsInSession)
                    {
                        result = new StatementResult(FunctionTable.ResultTable(request, 0));
                    }
                    else
                    {
                        result = new StatementResult();
                    }
                } catch (Exception ex) {
                    result = new StatementResult(ex);
                }

                results[i] = result;
            }

            return(results);
        }
Пример #5
0
 public void Handle(ExecutionContext context)
 {
     throw new NotImplementedException();
 }