Exemplo n.º 1
0
        /// <summary>
        /// Adds an operation to patch an item into the batch.
        /// </summary>
        /// <param name="id">The cosmos item id.</param>
        /// <param name="patchOperations">Represents a list of operations to be sequentially applied to the referred Cosmos item.</param>
        /// <param name="requestOptions">(Optional) The options for the Patch request. <see cref="TransactionalBatchPatchItemRequestOptions"/>.</param>
        /// <returns>The <see cref="TransactionalBatch"/> instance with the operation added.</returns>
        public override TransactionalBatch PatchItem(
            string id,
            IReadOnlyList <PatchOperation> patchOperations,
            TransactionalBatchPatchItemRequestOptions requestOptions = null)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException(nameof(id));
            }

            if (patchOperations == null ||
                !patchOperations.Any())
            {
                throw new ArgumentNullException(nameof(patchOperations));
            }

            PatchSpec patchSpec = new PatchSpec(patchOperations, requestOptions);

            this.operations.Add(new ItemBatchOperation <PatchSpec>(
                                    operationType: OperationType.Patch,
                                    operationIndex: this.operations.Count,
                                    id: id,
                                    resource: patchSpec,
                                    requestOptions: requestOptions,
                                    containerCore: this.container));

            return(this);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds an operation to patch an item into the batch.
        /// </summary>
        /// <param name="id">The cosmos item id.</param>
        /// <param name="patchStream">A <see cref="Stream"/> containing the patch specification.</param>
        /// <param name="requestOptions">(Optional) The options for the patch request. <see cref="TransactionalBatchPatchItemRequestOptions"/>.</param>
        /// <returns>The <see cref="TransactionalBatch"/> instance with the operation added.</returns>
        public virtual TransactionalBatch PatchItemStream(
            string id,
            Stream patchStream,
            TransactionalBatchPatchItemRequestOptions requestOptions = null)
        {
            this.operations.Add(new ItemBatchOperation(
                                    operationType: OperationType.Patch,
                                    operationIndex: this.operations.Count,
                                    id: id,
                                    resourceStream: patchStream,
                                    requestOptions: requestOptions,
                                    containerCore: this.container));

            return(this);
        }
 /// <summary>
 /// Adds an operation to patch an item into the batch.
 /// </summary>
 /// <param name="id">The unique id of the item.</param>
 /// <param name="patchOperations">Represents a list of operations to be sequentially applied to the referred Cosmos item.</param>
 /// <param name="requestOptions">(Optional) The options for the item request.</param>
 /// <returns>The transactional batch instance with the operation added.</returns>
 public abstract TransactionalBatch PatchItem(
     string id,
     System.Collections.Generic.IReadOnlyList <PatchOperation> patchOperations,
     TransactionalBatchPatchItemRequestOptions requestOptions = null);