Skip to content

DynamoDBStorage Methods

Wrapper around AWS DynamoDB SDK.

ConvertUpdate(Dictionary<string, AttributeValue>, Dictionary<string, AttributeValue>, string, Dictionary<string, AttributeValue>)

View source
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

fieldsDictionary<string, AttributeValue>
conditionValuesDictionary<string, AttributeValue>
extraExpressionstring
extraExpressionValuesDictionary<string, AttributeValue>

DeleteEntryAsync(string, Dictionary<string, AttributeValue>, string, Dictionary<string, AttributeValue>)

View source
public Task DeleteEntryAsync(string tableName, Dictionary<string, AttributeValue> keys, string conditionExpression = "", Dictionary<string, AttributeValue>? conditionValues = null)
Delete an entry from a DynamoDB table

Parameters

tableNamestring
The name of the table to delete an entry
keysDictionary<string, AttributeValue>
The table entry keys for the entry to be deleted
conditionExpressionstring
Optional conditional expression
conditionValuesDictionary<string, AttributeValue>
Optional field/attribute values used in the conditional expression

GetEntriesTxAsync(string, IEnumerable<Dictionary<string, AttributeValue>>, Func<Dictionary<string, AttributeValue>, TResult>)

View source
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

tableNamestring
The name of the table to search for the entry
keysIEnumerable<Dictionary<string, AttributeValue>>
The table entry keys to search for
resolverFunc<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<KeySchemaElement>, List<AttributeDefinition>, List<GlobalSecondaryIndex>, string?, CancellationToken)

View source
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

tableNamestring
The name of the table
keysList<KeySchemaElement>
The keys definitions
attributesList<AttributeDefinition>
The attributes used on the key definition
secondaryIndexesList<GlobalSecondaryIndex>
(optional) The secondary index definitions
ttlAttributeNamestring?
(optional) The name of the item attribute that indicates the item TTL (if null, ttl won't be enabled)
cancellationTokenCancellationToken
The cancellation token.

PutEntriesAsync(string, IReadOnlyCollection<Dictionary<string, AttributeValue>>)

View source
public Task PutEntriesAsync(string tableName, IReadOnlyCollection<Dictionary<string, AttributeValue>> toCreate)
Crete or replace multiple entries in a DynamoDB table (Batch put)

Parameters

tableNamestring
The name of the table to search for the entry
toCreateIReadOnlyCollection<Dictionary<string, AttributeValue>>
List of key values for each entry that must be created or replaced in the batch

PutEntryAsync(string, Dictionary<string, AttributeValue>, string, Dictionary<string, AttributeValue>)

View source
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

tableNamestring
The name of the table to put an entry
fieldsDictionary<string, AttributeValue>
The fields/attributes to add or replace in the table
conditionExpressionstring
Optional conditional expression
conditionValuesDictionary<string, AttributeValue>
Optional field/attribute values used in the conditional expression

QueryAllAsync(string, Dictionary<string, AttributeValue>, string, Func<Dictionary<string, AttributeValue>, TResult>, string, bool, bool)

View source
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

tableNamestring
The name of the table to search for the entries
keysDictionary<string, AttributeValue>
The table entry keys to search for
keyConditionExpressionstring
the expression that will filter the keys
resolverFunc<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
indexNamestring
In case a secondary index is used in the keyConditionExpression
scanIndexForwardbool
In case an index is used, show if the seek order is ascending (true) or descending (false)
consistentReadbool
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<string, AttributeValue>, string, Func<Dictionary<string, AttributeValue>, TResult>, string, bool, Dictionary<string, AttributeValue>, bool)

View source
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

tableNamestring
The name of the table to search for the entries
keysDictionary<string, AttributeValue>
The table entry keys to search for
keyConditionExpressionstring
the expression that will filter the keys
resolverFunc<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
indexNamestring
In case a secondary index is used in the keyConditionExpression
scanIndexForwardbool
In case an index is used, show if the seek order is ascending (true) or descending (false)
lastEvaluatedKeyDictionary<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
consistentReadbool
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<string, AttributeValue>, Func<Dictionary<string, AttributeValue>, TResult>)

View source
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

tableNamestring
The name of the table to search for the entry
keysDictionary<string, AttributeValue>
The table entry keys to search for
resolverFunc<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<string, AttributeValue>, string, Func<Dictionary<string, AttributeValue>, TResult>)

View source
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

tableNamestring
The name of the table to search for the entries
attributesDictionary<string, AttributeValue>
The attributes used on the expression
expressionstring
The filter expression
resolverFunc<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<string, AttributeValue>, Dictionary<string, AttributeValue>, string, Dictionary<string, AttributeValue>, string, Dictionary<string, AttributeValue>)

View source
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

tableNamestring
The name of the table to upsert an entry
keysDictionary<string, AttributeValue>
The table entry keys for the entry
fieldsDictionary<string, AttributeValue>
The fields/attributes to add or updated in the table
conditionExpressionstring
Optional conditional expression
conditionValuesDictionary<string, AttributeValue>
Optional field/attribute values used in the conditional expression
extraExpressionstring
Additional expression that will be added in the end of the upsert expression
extraExpressionValuesDictionary<string, AttributeValue>
Additional field/attribute that will be used in the extraExpression

WriteTxAsync(IEnumerable<Put>, IEnumerable<Update>, IEnumerable<Delete>, IEnumerable<ConditionCheck>)

View source
public Task WriteTxAsync(IEnumerable<Put>? puts = null, IEnumerable<Update>? updates = null, IEnumerable<Delete>? deletes = null, IEnumerable<ConditionCheck>? conditionChecks = null)
Transactionally performs write requests

Parameters

putsIEnumerable<Put>
Any puts to be performed
updatesIEnumerable<Update>
Any updated to be performed
deletesIEnumerable<Delete>
Any deletes to be performed
conditionChecksIEnumerable<ConditionCheck>
Any condition checks to be performed