# DynamoDBStorage Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/)

## ConvertUpdate(Dictionary&lt;string, AttributeValue&gt;, Dictionary&lt;string, AttributeValue&gt;, string, Dictionary&lt;string, AttributeValue&gt;) {#convertupdate-system-collections-generic-dictionary-string-amazon-dynamodbv2-mod-1c8ef617}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/convertupdate-system-collections-generic-dictionary-string-amazon-dynamodbv2-mod-1c8ef617/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L565-L600)

```csharp
public (string updateExpression, Dictionary<string, AttributeValue> expressionAttributeValues) DynamoDBStorage.ConvertUpdate(Dictionary<string, AttributeValue> fields, Dictionary<string, AttributeValue>? conditionValues = null, string extraExpression = "", Dictionary<string, AttributeValue>? extraExpressionValues = null)
```

### Parameters

- `fields` (`Dictionary<string, AttributeValue>`)
- `conditionValues` (`Dictionary<string, AttributeValue>`)
- `extraExpression` (`string`)
- `extraExpressionValues` (`Dictionary<string, AttributeValue>`)

## DeleTableAsync(string) {#deletableasync-string-b5cba76b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/deletableasync-string-b5cba76b/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L467-L474)

```csharp
public Task DeleTableAsync(string tableName)
```

Delete a table from DynamoDB

### Parameters

- `tableName` (`string`): The name of the table to delete

## DeleteEntriesAsync(string, IReadOnlyCollection&lt;Dictionary&lt;string, AttributeValue&gt;&gt;) {#deleteentriesasync-string-system-collections-generic-ireadonlycollection-system-24a987df}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/deleteentriesasync-string-system-collections-generic-ireadonlycollection-system-24a987df/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L646-L674)

```csharp
public Task DeleteEntriesAsync(string tableName, IReadOnlyCollection<Dictionary<string, AttributeValue>> toDelete)
```

Delete multiple entries from a DynamoDB table (Batch delete)

### Parameters

- `tableName` (`string`): The name of the table to delete entries
- `toDelete` (`IReadOnlyCollection<Dictionary<string, AttributeValue>>`): List of key values for each entry that must be deleted in the batch

## DeleteEntryAsync(string, Dictionary&lt;string, AttributeValue&gt;, string, Dictionary&lt;string, AttributeValue&gt;) {#deleteentryasync-string-system-collections-generic-dictionary-string-amazon-dyna-2cfabb67}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/deleteentryasync-string-system-collections-generic-dictionary-string-amazon-dyna-2cfabb67/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L613-L636)

```csharp
public Task DeleteEntryAsync(string tableName, Dictionary<string, AttributeValue> keys, string conditionExpression = "", Dictionary<string, AttributeValue>? conditionValues = null)
```

Delete an entry from a DynamoDB table

### Parameters

- `tableName` (`string`): The name of the table to delete an entry
- `keys` (`Dictionary<string, AttributeValue>`): The table entry keys for the entry to be deleted
- `conditionExpression` (`string`): Optional conditional expression
- `conditionValues` (`Dictionary<string, AttributeValue>`): Optional field/attribute values used in the conditional expression

## GetEntriesTxAsync(string, IEnumerable&lt;Dictionary&lt;string, AttributeValue&gt;&gt;, Func&lt;Dictionary&lt;string, AttributeValue&gt;, TResult&gt;) {#getentriestxasync-1-string-system-collections-generic-ienumerable-system-collect-da7ed784}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/getentriestxasync-1-string-system-collections-generic-ienumerable-system-collect-da7ed784/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L920-L941)

```csharp
public Task<IEnumerable<TResult>> GetEntriesTxAsync<TResult>(string tableName, IEnumerable<Dictionary<string, AttributeValue>> keys, Func<Dictionary<string, AttributeValue>, TResult> resolver)
```

Transactionally reads entries from a DynamoDB table

### Parameters

- `tableName` (`string`): The name of the table to search for the entry
- `keys` (`IEnumerable<Dictionary<string, AttributeValue>>`): The table entry keys to search for
- `resolver` (`Func<Dictionary<string, AttributeValue>, TResult>`): Function that will be called to translate the returned fields into a concrete type. This Function is only called if the result is != null

### Returns

The object translated by the resolver function

## InitializeTable(string, List&lt;KeySchemaElement&gt;, List&lt;AttributeDefinition&gt;, List&lt;GlobalSecondaryIndex&gt;, string?, CancellationToken) {#initializetable-string-system-collections-generic-list-amazon-dynamodbv2-model-k-90257b7f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/initializetable-string-system-collections-generic-list-amazon-dynamodbv2-model-k-90257b7f/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L113-L137)

```csharp
public Task InitializeTable(string tableName, List<KeySchemaElement> keys, List<AttributeDefinition> attributes, List<GlobalSecondaryIndex>? secondaryIndexes = null, string? ttlAttributeName = null, CancellationToken cancellationToken = default(CancellationToken))
```

Create a DynamoDB table if it doesn't exist

### Parameters

- `tableName` (`string`): The name of the table
- `keys` (`List<KeySchemaElement>`): The keys definitions
- `attributes` (`List<AttributeDefinition>`): The attributes used on the key definition
- `secondaryIndexes` (`List<GlobalSecondaryIndex>`): (optional) The secondary index definitions
- `ttlAttributeName` (`string?`): (optional) The name of the item attribute that indicates the item TTL (if null, ttl won't be enabled)
- `cancellationToken` (`CancellationToken`): The cancellation token.

## PutEntriesAsync(string, IReadOnlyCollection&lt;Dictionary&lt;string, AttributeValue&gt;&gt;) {#putentriesasync-string-system-collections-generic-ireadonlycollection-system-col-2c6516a4}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/putentriesasync-string-system-collections-generic-ireadonlycollection-system-col-2c6516a4/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L878-L906)

```csharp
public Task PutEntriesAsync(string tableName, IReadOnlyCollection<Dictionary<string, AttributeValue>> toCreate)
```

Crete or replace multiple entries in a DynamoDB table (Batch put)

### Parameters

- `tableName` (`string`): The name of the table to search for the entry
- `toCreate` (`IReadOnlyCollection<Dictionary<string, AttributeValue>>`): List of key values for each entry that must be created or replaced in the batch

## PutEntryAsync(string, Dictionary&lt;string, AttributeValue&gt;, string, Dictionary&lt;string, AttributeValue&gt;) {#putentryasync-string-system-collections-generic-dictionary-string-amazon-dynamod-b74b7f04}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/putentryasync-string-system-collections-generic-dictionary-string-amazon-dynamod-b74b7f04/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L486-L504)

```csharp
public Task PutEntryAsync(string tableName, Dictionary<string, AttributeValue> fields, string conditionExpression = "", Dictionary<string, AttributeValue>? conditionValues = null)
```

Create or Replace an entry in a DynamoDB Table

### Parameters

- `tableName` (`string`): The name of the table to put an entry
- `fields` (`Dictionary<string, AttributeValue>`): The fields/attributes to add or replace in the table
- `conditionExpression` (`string`): Optional conditional expression
- `conditionValues` (`Dictionary<string, AttributeValue>`): Optional field/attribute values used in the conditional expression

## QueryAllAsync(string, Dictionary&lt;string, AttributeValue&gt;, string, Func&lt;Dictionary&lt;string, AttributeValue&gt;, TResult&gt;, string, bool, bool) {#queryallasync-1-string-system-collections-generic-dictionary-string-amazon-dynam-abe1cbd1}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/queryallasync-1-string-system-collections-generic-dictionary-string-amazon-dynam-abe1cbd1/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L782-L800)

```csharp
public Task<List<TResult>> QueryAllAsync<TResult>(string tableName, Dictionary<string, AttributeValue> keys, string keyConditionExpression, Func<Dictionary<string, AttributeValue>, TResult> resolver, string indexName = "", bool scanIndexForward = true, bool consistentRead = true)
```

Query for multiple entries in a DynamoDB table by filtering its keys

### Parameters

- `tableName` (`string`): The name of the table to search for the entries
- `keys` (`Dictionary<string, AttributeValue>`): The table entry keys to search for
- `keyConditionExpression` (`string`): the expression that will filter the keys
- `resolver` (`Func<Dictionary<string, AttributeValue>, TResult>`): Function that will be called to translate the returned fields into a concrete type. This Function is only called if the result is != null and will be called for each entry that match the query and added to the results list
- `indexName` (`string`): In case a secondary index is used in the keyConditionExpression
- `scanIndexForward` (`bool`): In case an index is used, show if the seek order is ascending (true) or descending (false)
- `consistentRead` (`bool`): Determines the read consistency model. Note that if a GSI is used, this must be false.

### Returns

The collection containing a list of objects translated by the resolver function

## QueryAsync(string, Dictionary&lt;string, AttributeValue&gt;, string, Func&lt;Dictionary&lt;string, AttributeValue&gt;, TResult&gt;, string, bool, Dictionary&lt;string, AttributeValue&gt;, bool) {#queryasync-1-string-system-collections-generic-dictionary-string-amazon-dynamodb-62ed348f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/queryasync-1-string-system-collections-generic-dictionary-string-amazon-dynamodb-62ed348f/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L730-L764)

```csharp
public Task<(List<TResult> results, Dictionary<string, AttributeValue>? lastEvaluatedKey)> DynamoDBStorage.QueryAsync<TResult>(string tableName, Dictionary<string, AttributeValue> keys, string keyConditionExpression, Func<Dictionary<string, AttributeValue>, TResult> resolver, string indexName = "", bool scanIndexForward = true, Dictionary<string, AttributeValue>? lastEvaluatedKey = null, bool consistentRead = true)
```

Query for multiple entries in a DynamoDB table by filtering its keys

### Parameters

- `tableName` (`string`): The name of the table to search for the entries
- `keys` (`Dictionary<string, AttributeValue>`): The table entry keys to search for
- `keyConditionExpression` (`string`): the expression that will filter the keys
- `resolver` (`Func<Dictionary<string, AttributeValue>, TResult>`): Function that will be called to translate the returned fields into a concrete type. This Function is only called if the result is != null and will be called for each entry that match the query and added to the results list
- `indexName` (`string`): In case a secondary index is used in the keyConditionExpression
- `scanIndexForward` (`bool`): In case an index is used, show if the seek order is ascending (true) or descending (false)
- `lastEvaluatedKey` (`Dictionary<string, AttributeValue>`): The primary key of the first item that this operation will evaluate. Use the value that was returned for LastEvaluatedKey in the previous operation
- `consistentRead` (`bool`): Determines the read consistency model. Note that if a GSI is used, this must be false.

### Returns

The collection containing a list of objects translated by the resolver function and the LastEvaluatedKey for paged results

## ReadSingleEntryAsync(string, Dictionary&lt;string, AttributeValue&gt;, Func&lt;Dictionary&lt;string, AttributeValue&gt;, TResult&gt;) {#readsingleentryasync-1-string-system-collections-generic-dictionary-string-amazo-e6f6de4d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/readsingleentryasync-1-string-system-collections-generic-dictionary-string-amazo-e6f6de4d/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L688-L711)

```csharp
public Task<TResult?> ReadSingleEntryAsync<TResult>(string tableName, Dictionary<string, AttributeValue> keys, Func<Dictionary<string, AttributeValue>, TResult> resolver)
```

Read an entry from a DynamoDB table

### Parameters

- `tableName` (`string`): The name of the table to search for the entry
- `keys` (`Dictionary<string, AttributeValue>`): The table entry keys to search for
- `resolver` (`Func<Dictionary<string, AttributeValue>, TResult>`): Function that will be called to translate the returned fields into a concrete type. This Function is only called if the result is != null

### Returns

The object translated by the resolver function

## ScanAsync(string, Dictionary&lt;string, AttributeValue&gt;, string, Func&lt;Dictionary&lt;string, AttributeValue&gt;, TResult&gt;) {#scanasync-1-string-system-collections-generic-dictionary-string-amazon-dynamodbv-aeffb5c9}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/scanasync-1-string-system-collections-generic-dictionary-string-amazon-dynamodbv-aeffb5c9/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L821-L868)

```csharp
public Task<List<TResult>> ScanAsync<TResult>(string tableName, Dictionary<string, AttributeValue> attributes, string expression, Func<Dictionary<string, AttributeValue>, TResult> resolver)
```

Scan a DynamoDB table by querying the entry fields.

### Parameters

- `tableName` (`string`): The name of the table to search for the entries
- `attributes` (`Dictionary<string, AttributeValue>`): The attributes used on the expression
- `expression` (`string`): The filter expression
- `resolver` (`Func<Dictionary<string, AttributeValue>, TResult>`): Function that will be called to translate the returned fields into a concrete type. This Function is only called if the result is != null and will be called for each entry that match the query and added to the results list

### Returns

The collection containing a list of objects translated by the resolver function

## UpsertEntryAsync(string, Dictionary&lt;string, AttributeValue&gt;, Dictionary&lt;string, AttributeValue&gt;, string, Dictionary&lt;string, AttributeValue&gt;, string, Dictionary&lt;string, AttributeValue&gt;) {#upsertentryasync-string-system-collections-generic-dictionary-string-amazon-dyna-9b544f57}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/upsertentryasync-string-system-collections-generic-dictionary-string-amazon-dyna-9b544f57/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L522-L558)

```csharp
public Task UpsertEntryAsync(string tableName, Dictionary<string, AttributeValue> keys, Dictionary<string, AttributeValue> fields, string conditionExpression = "", Dictionary<string, AttributeValue>? conditionValues = null, string extraExpression = "", Dictionary<string, AttributeValue>? extraExpressionValues = null)
```

Create or update an entry in a DynamoDB Table

### Parameters

- `tableName` (`string`): The name of the table to upsert an entry
- `keys` (`Dictionary<string, AttributeValue>`): The table entry keys for the entry
- `fields` (`Dictionary<string, AttributeValue>`): The fields/attributes to add or updated in the table
- `conditionExpression` (`string`): Optional conditional expression
- `conditionValues` (`Dictionary<string, AttributeValue>`): Optional field/attribute values used in the conditional expression
- `extraExpression` (`string`): Additional expression that will be added in the end of the upsert expression
- `extraExpressionValues` (`Dictionary<string, AttributeValue>`): Additional field/attribute that will be used in the extraExpression

## WriteTxAsync(IEnumerable&lt;Put&gt;, IEnumerable&lt;Update&gt;, IEnumerable&lt;Delete&gt;, IEnumerable&lt;ConditionCheck&gt;) {#writetxasync-system-collections-generic-ienumerable-amazon-dynamodbv2-model-put-f469a118}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/writetxasync-system-collections-generic-ienumerable-amazon-dynamodbv2-model-put-f469a118/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L955-L985)

```csharp
public Task WriteTxAsync(IEnumerable<Put>? puts = null, IEnumerable<Update>? updates = null, IEnumerable<Delete>? deletes = null, IEnumerable<ConditionCheck>? conditionChecks = null)
```

Transactionally performs write requests

### Parameters

- `puts` (`IEnumerable<Put>`): Any puts to be performed
- `updates` (`IEnumerable<Update>`): Any updated to be performed
- `deletes` (`IEnumerable<Delete>`): Any deletes to be performed
- `conditionChecks` (`IEnumerable<ConditionCheck>`): Any condition checks to be performed

## WriteTxAsync(List&lt;TransactWriteItem&gt;) {#writetxasync-system-collections-generic-list-amazon-dynamodbv2-model-transactwri-0953dc0c}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.transactions.dynamodb/orleans.transactions.dynamodb.dynamodbstorage/methods/writetxasync-system-collections-generic-list-amazon-dynamodbv2-model-transactwri-0953dc0c/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/AWS/Shared/Storage/DynamoDBStorage.cs#L996-L1008)

```csharp
public Task WriteTxAsync(List<TransactWriteItem> transactItems)
```

Transactionally performs write requests

### Parameters

- `transactItems` (`List<TransactWriteItem>`): Transact write items to be performed
