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); } }
public void DeleteItemInCosmos(string itemId) { transactionalBatch.DeleteItem(itemId); }
public override void Apply(TransactionalBatch transactionalBatch, PartitionKeyPath partitionKeyPath) { transactionalBatch.DeleteItem(id, options); }