예제 #1
0
 /// <summary>
 /// Asynchronously executes all registered requests,
 /// optionally skipping the last requests according to
 /// <paramref name="context.AllowPartialExecution"/> argument.
 /// Default implementation executes requests synchronously and returns completed task.
 /// </summary>
 /// <remarks> Multiple active operations are not supported. Use <see langword="await"/>
 /// to ensure that all asynchronous operations have completed.</remarks>
 /// <param name="context">A contextual information to be used while executing
 /// registered query requests.</param>
 /// <param name="token">Token to cancel this operation</param>
 /// <returns>A task preforming this operation.</returns>
 public virtual Task ExecuteTasksAsync(CommandProcessorContext context, CancellationToken token)
 {
     token.ThrowIfCancellationRequested();
     ExecuteTasks(context);
     return(Task.CompletedTask);
 }
        public override async Task <DataReader> ExecuteTasksWithReaderAsync(QueryRequest lastRequest, CommandProcessorContext context, CancellationToken token)
        {
            var oldValue = context.AllowPartialExecution;

            context.AllowPartialExecution = false;

            token.ThrowIfCancellationRequested();

            await ExecuteTasksAsync(context, token).ConfigureAwait(false);

            context.AllowPartialExecution = oldValue;

            var lastRequestCommand = Factory.CreateCommand();
            var commandPart        = Factory.CreateQueryPart(lastRequest, context.ParameterContext);

            ValidateCommandParameters(commandPart);
            lastRequestCommand.AddPart(commandPart);
            token.ThrowIfCancellationRequested();
            await lastRequestCommand.ExecuteReaderAsync(token).ConfigureAwait(false);

            return(lastRequestCommand.CreateReader(lastRequest.GetAccessor()));
        }
예제 #3
0
 /// <summary>
 /// Asynchronously executes all registered requests plus the specified one query.
 /// Default implementation is synchronous and returns complete task.
 /// </summary>
 /// <remarks> Multiple active operations are not supported. Use <see langword="await"/>
 /// to ensure that all asynchronous operations have completed.</remarks>
 /// <param name="request">The request to execute.</param>
 /// <param name="context">A contextual information to be used while executing
 /// the specified <paramref name="request"/>.</param>
 /// <param name="token">Token to cancel operation.</param>
 /// <returns>A task performing this operation.</returns>
 public virtual Task <DataReader> ExecuteTasksWithReaderAsync(QueryRequest request,
                                                              CommandProcessorContext context, CancellationToken token)
 {
     token.ThrowIfCancellationRequested();
     return(Task.FromResult(ExecuteTasksWithReader(request, context)));
 }
예제 #4
0
 /// <summary>
 /// Executes all registered requests,
 /// optionally skipping the last requests according to
 /// <paramref name="context.AllowPartialExecution"/> argument.
 /// </summary>
 /// <param name="context">The context in which the requests are executed.</param>
 public abstract void ExecuteTasks(CommandProcessorContext context);
예제 #5
0
 /// <summary>
 /// Executes all registered requests plus the specified one query,
 /// returning <see cref="IEnumerator{Tuple}"/> for the last query.
 /// </summary>
 /// <param name="request">A <see cref="QueryRequest"/> instance to be executed.</param>
 /// <param name="context">A contextual information to be used while executing
 /// the specified <paramref name="request"/>.</param>
 /// <returns>A <see cref="IEnumerator{Tuple}"/> for the specified request.</returns>
 public abstract DataReader ExecuteTasksWithReader(QueryRequest request, CommandProcessorContext context);
 async Task <IEnumerator <Tuple> > IProviderExecutor.ExecuteTupleReaderAsync(QueryRequest request, CancellationToken token)
 {
     Prepare();
     using (var context = new CommandProcessorContext())
         return(await commandProcessor.ExecuteTasksWithReaderAsync(request, context, token).ConfigureAwait(false));
 }
        public override async Task <IEnumerator <Tuple> > ExecuteTasksWithReaderAsync(QueryRequest lastRequest, CommandProcessorContext context, CancellationToken token)
        {
            var oldValue = context.AllowPartialExecution;

            context.AllowPartialExecution = false;

            token.ThrowIfCancellationRequested();

            await ExecuteTasksAsync(context, token);

            context.AllowPartialExecution = oldValue;

            var lastRequestCommand = Factory.CreateCommand();
            var commandPart        = Factory.CreateQueryPart(lastRequest);

            lastRequestCommand.AddPart(commandPart);
            token.ThrowIfCancellationRequested();
            await lastRequestCommand.ExecuteReaderAsync(token);

            return(lastRequestCommand.AsReaderOf(lastRequest));
        }
        public override IEnumerator <Tuple> ExecuteTasksWithReader(QueryRequest lastRequest, CommandProcessorContext context)
        {
            var oldValue = context.AllowPartialExecution;

            context.AllowPartialExecution = false;
            ExecuteTasks(context);
            context.AllowPartialExecution = oldValue;

            var lastRequestCommand = Factory.CreateCommand();
            var commandPart        = Factory.CreateQueryPart(lastRequest);

            lastRequestCommand.AddPart(commandPart);
            lastRequestCommand.ExecuteReader();
            return(lastRequestCommand.AsReaderOf(lastRequest));
        }
예제 #9
0
 /// <inheritdoc/>
 public override void ProcessWith(ISqlTaskProcessor processor, CommandProcessorContext context)
 {
     processor.ProcessTask(this, context);
 }