예제 #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.</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,
                       (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);
            }));
        }
예제 #2
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);
            },
                       (response) => new OpenTelemetryResponse(response)));
        }