コード例 #1
0
        /// <summary>
        /// Executes the batch at the Azure Cosmos service as an asynchronous operation.
        /// </summary>
        /// <param name="requestOptions">Options that apply to the batch. Used only for EPK routing.</param>
        /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
        /// <returns>An awaitable <see cref="TransactionalBatchResponse"/> which contains the completion status and results of each operation.</returns>
        public virtual Task <TransactionalBatchResponse> ExecuteAsync(
            RequestOptions requestOptions,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            BatchExecutor executor = new BatchExecutor(this.container, this.partitionKey, this.operations, requestOptions);

            this.operations = new List <ItemBatchOperation>();
            return(executor.ExecuteAsync(cancellationToken));
        }
コード例 #2
0
        internal Task <BatchResponse> ExecuteAsync(
            int maxServerRequestBodyLength,
            int maxServerRequestOperationCount,
            RequestOptions requestOptions       = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            BatchExecutor executor = new BatchExecutor(this.container, this.partitionKey, this.operations, requestOptions, maxServerRequestBodyLength, maxServerRequestOperationCount);

            this.operations = new List <ItemBatchOperation>();
            return(executor.ExecuteAsync(cancellationToken));
        }
コード例 #3
0
        /// <summary>
        /// Executes the batch at the Azure Cosmos service as an asynchronous operation.
        /// </summary>
        /// <param name="requestOptions">Options that apply to the batch. Used only for EPK routing.</param>
        /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
        /// <returns>An awaitable <see cref="TransactionalBatchResponse"/> which contains the completion status and results of each operation.</returns>
        public virtual Task <TransactionalBatchResponse> ExecuteAsync(
            RequestOptions requestOptions,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            CosmosDiagnosticsContext diagnosticsContext = CosmosDiagnosticsContext.Create(requestOptions);
            BatchExecutor            executor           = new BatchExecutor(
                container: this.container,
                partitionKey: this.partitionKey,
                operations: this.operations,
                batchOptions: requestOptions,
                diagnosticsContext: diagnosticsContext);

            this.operations = new List <ItemBatchOperation>();
            return(executor.ExecuteAsync(cancellationToken));
        }
コード例 #4
0
        /// <summary>
        /// Executes the batch at the Azure Cosmos service as an asynchronous operation.
        /// </summary>
        /// <param name="requestOptions">Options that apply to the batch.</param>
        /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
        /// <returns>An awaitable <see cref="TransactionalBatchResponse"/> which contains the completion status and results of each operation.</returns>
        public override Task <TransactionalBatchResponse> ExecuteAsync(
            TransactionalBatchRequestOptions requestOptions,
            CancellationToken cancellationToken = default)
        {
            return(this.container.ClientContext.OperationHelperAsync(
                       nameof(ExecuteAsync),
                       requestOptions,
                       (trace) =>
            {
                BatchExecutor executor = new BatchExecutor(
                    container: this.container,
                    partitionKey: this.partitionKey,
                    operations: this.operations,
                    batchOptions: requestOptions);

                this.operations = new List <ItemBatchOperation>();
                return executor.ExecuteAsync(trace, cancellationToken);
            }));
        }
コード例 #5
0
        /// <summary>
        /// Executes the batch at the Azure Cosmos service as an asynchronous operation.
        /// </summary>
        /// <param name="requestOptions">Options that apply to the batch. Used only for EPK routing.</param>
        /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
        /// <returns>An awaitable <see cref="TransactionalBatchResponse"/> which contains the completion status and results of each operation.</returns>
        public virtual Task <TransactionalBatchResponse> ExecuteAsync(
            RequestOptions requestOptions,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            return(this.container.ClientContext.OperationHelperAsync(
                       nameof(ExecuteAsync),
                       requestOptions,
                       (diagnostics) =>
            {
                BatchExecutor executor = new BatchExecutor(
                    container: this.container,
                    partitionKey: this.partitionKey,
                    operations: this.operations,
                    batchOptions: requestOptions,
                    diagnosticsContext: diagnostics);

                this.operations = new List <ItemBatchOperation>();
                return executor.ExecuteAsync(cancellationToken);
            }));
        }