# DeleteMultiple with ARX.SDK on Amazon DynamoDB

## What a DeleteMultiple does

| Rule | On DynamoDB |
|---|---|
| Many items | DeleteMultiple sends the deletes in one transaction (up to 100), each conditioned on its item existing; one that isn't is left out and the rest sent again, so the count is exact and the deletes all or nothing (one round trip when all are there) |

## The samples

Every DeleteMultiple sample, in reading order. Each scenario shows the code (verified against DynamoDB Local) and the PartiQL statement that checks what it did. `service` is the application's `ArxDynamoDbService`; values marked "In scope" come from earlier in the sample. What the samples' code refers to beyond the packages (SampleCatalog.cs, `dbContext`) is in the sample application file, arx-dynamodb-sample-application.md.

### Delete many records in one call

Basics 1 of DeleteMultiple.

Many items in one call: three SKUs, one of them unknown. The two found go, in one transaction, and the call returns how many.

Good to know:

The deletes are sent conditioned on each item, without a read first, as one `TransactWriteItems` of at most 100 items (more is ARX8001 unless `AllowPartial`). An id no item has isn't an error; it isn't counted. Delete's "How to find the items" sample deletes many by columns a key or an index gives.

Usings:

```csharp
using ARX.SDK.DynamoDb.Services;
using ARX.SDK.Services;
```

Set up by the sample before its scenarios:

```csharp
var products = new[] { "SKU-D302", "SKU-D303", "SKU-D304" }.Select(sku =>
{
    var product = new ArxEntity("product");
    product["sku"] = sku;
    product["name"] = $"Clearance item {sku}";
    return product;
}).ToList();
await service.CreateMultipleAsync(products);
```

#### 1. Several ids at once

Three SKUs, one of them unknown: the two found go, in one transaction.

In scope: `service` (ArxDynamoDbService).

```csharp
int deleted = await service.DeleteMultipleAsync("product", new[] { "SKU-D302", "SKU-D303", "SKU-D399" });

Console.WriteLine($"{deleted} items deleted");
```

Check it in the database:

```sql
SELECT "sku" FROM "product" WHERE "sku" IN ['SKU-D302', 'SKU-D303', 'SKU-D304']
```

Expect: 1 item, SKU-D304.

