コード例 #1
0
        public async ValueTask DeleteAsBatchAsync(
            IEnumerable <TItem> items,
            CancellationToken cancellationToken = default)
        {
            List <TItem> list = items.ToList();

            string partitionKey = GetPartitionKeyValue(list);

            Container container = await _containerProvider.GetContainerAsync();

            TransactionalBatch batch = container.CreateTransactionalBatch(new PartitionKey(partitionKey));

            foreach (TItem item in list)
            {
                batch.DeleteItem(item.Id);
            }

            using TransactionalBatchResponse response = await batch.ExecuteAsync(cancellationToken);

            if (!response.IsSuccessStatusCode)
            {
                throw new BatchOperationException <TItem>(response);
            }
        }
コード例 #2
0
 public void DeleteItemInCosmos(string itemId)
 {
     transactionalBatch.DeleteItem(itemId);
 }
コード例 #3
0
 public override void Apply(TransactionalBatch transactionalBatch, PartitionKeyPath partitionKeyPath)
 {
     transactionalBatch.DeleteItem(id, options);
 }