Class DynamoDBContext
- Namespace
- Amazon.DynamoDBv2.DataModel
- Assembly
- AWSSDK.DynamoDBv2.dll
Context object for using the DataModel mode of DynamoDB. Used to interact with the service, save/load objects, etc.
public class DynamoDBContext : IDynamoDBContext, IDisposable
- Inheritance
-
DynamoDBContext
- Implements
- Inherited Members
Constructors
DynamoDBContext(IAmazonDynamoDB)
Constructs a DynamoDBContext object with the specified DynamoDB client. Uses default DynamoDBContextConfig object for configuration.
public DynamoDBContext(IAmazonDynamoDB client)
Parameters
clientIAmazonDynamoDBClient to use for making calls
DynamoDBContext(IAmazonDynamoDB, DynamoDBContextConfig)
Constructs a DynamoDBContext object with the specified DynamoDB client and configuration.
public DynamoDBContext(IAmazonDynamoDB client, DynamoDBContextConfig config)
Parameters
clientIAmazonDynamoDBClient to use for making calls
configDynamoDBContextConfigConfiguration to use
Properties
ConverterCache
This cache is a way to store Converters for objects which provides a way to expand Context
public Dictionary<Type, IPropertyConverter> ConverterCache { get; }
Property Value
Methods
CreateBatchGet<T>()
Creates a strongly-typed BatchGet object, allowing a batch-get operation against DynamoDB.
public BatchGet<T> CreateBatchGet<T>()
Returns
- BatchGet<T>
Empty strongly-typed BatchGet object
Type Parameters
TType of objects to get
CreateBatchGet<T>(DynamoDBOperationConfig)
Creates a strongly-typed BatchGet object, allowing a batch-get operation against DynamoDB.
public BatchGet<T> CreateBatchGet<T>(DynamoDBOperationConfig operationConfig)
Parameters
operationConfigDynamoDBOperationConfigConfig object which can be used to override that table used.
Returns
- BatchGet<T>
Empty strongly-typed BatchGet object
Type Parameters
TType of objects to get
CreateBatchWrite<T>()
Creates a strongly-typed BatchWrite object, allowing a batch-write operation against DynamoDB.
public BatchWrite<T> CreateBatchWrite<T>()
Returns
- BatchWrite<T>
Empty strongly-typed BatchWrite object
Type Parameters
TType of objects to write
CreateBatchWrite<T>(DynamoDBOperationConfig)
Creates a strongly-typed BatchWrite object, allowing a batch-write operation against DynamoDB.
public BatchWrite<T> CreateBatchWrite<T>(DynamoDBOperationConfig operationConfig)
Parameters
operationConfigDynamoDBOperationConfigConfig object which can be used to override that table used.
Returns
- BatchWrite<T>
Empty strongly-typed BatchWrite object
Type Parameters
TType of objects to write
CreateMultiTableBatchGet(params BatchGet[])
Creates a MultiTableBatchGet object, composed of multiple individual BatchGet objects.
public MultiTableBatchGet CreateMultiTableBatchGet(params BatchGet[] batches)
Parameters
batchesBatchGet[]Individual BatchGet objects
Returns
- MultiTableBatchGet
Composite MultiTableBatchGet object
CreateMultiTableBatchWrite(params BatchWrite[])
Creates a MultiTableBatchWrite object, composed of multiple individual BatchWrite objects.
public MultiTableBatchWrite CreateMultiTableBatchWrite(params BatchWrite[] batches)
Parameters
batchesBatchWrite[]Individual BatchWrite objects
Returns
- MultiTableBatchWrite
Composite MultiTableBatchWrite object
DeleteAsync<T>(object, DynamoDBOperationConfig, CancellationToken)
Initiates the asynchronous execution of the Delete operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Delete
public Task DeleteAsync<T>(object hashKey, DynamoDBOperationConfig operationConfig, CancellationToken cancellationToken = default)
Parameters
hashKeyobjectHash key element of the object to delete.
operationConfigDynamoDBOperationConfigConfig object which can be used to override that table used.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType of object.
DeleteAsync<T>(object, object, DynamoDBOperationConfig, CancellationToken)
Initiates the asynchronous execution of the Delete operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Delete
public Task DeleteAsync<T>(object hashKey, object rangeKey, DynamoDBOperationConfig operationConfig, CancellationToken cancellationToken = default)
Parameters
hashKeyobjectHash key element of the object to delete.
rangeKeyobjectRange key element of the object to delete.
operationConfigDynamoDBOperationConfigConfig object which can be used to override that table used.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType of object.
DeleteAsync<T>(object, object, CancellationToken)
Initiates the asynchronous execution of the Delete operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Delete
public Task DeleteAsync<T>(object hashKey, object rangeKey, CancellationToken cancellationToken = default)
Parameters
hashKeyobjectHash key element of the object to delete.
rangeKeyobjectRange key element of the object to delete.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType of object.
DeleteAsync<T>(object, CancellationToken)
Initiates the asynchronous execution of the Delete operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Delete
public Task DeleteAsync<T>(object hashKey, CancellationToken cancellationToken = default)
Parameters
hashKeyobjectHash key element of the object to delete.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType of object.
DeleteAsync<T>(T, DynamoDBOperationConfig, CancellationToken)
Initiates the asynchronous execution of the Delete operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Delete
public Task DeleteAsync<T>(T value, DynamoDBOperationConfig operationConfig, CancellationToken cancellationToken = default)
Parameters
valueTObject to delete.
operationConfigDynamoDBOperationConfigOverriding configuration.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType of object.
DeleteAsync<T>(T, CancellationToken)
Initiates the asynchronous execution of the Delete operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Delete
public Task DeleteAsync<T>(T value, CancellationToken cancellationToken = default)
Parameters
valueTObject to delete.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType of object.
Dispose()
Disposes of all managed and unmanaged resources.
public void Dispose()
Dispose(bool)
Implements the Dispose pattern
protected virtual void Dispose(bool disposing)
Parameters
disposingboolWhether this object is being disposed via a call to Dispose or garbage collected.
ExecuteBatchGetAsync(params BatchGet[])
Issues a batch-get request with multiple batches.
Results are stored in the individual batches.
public Task ExecuteBatchGetAsync(params BatchGet[] batches)
Parameters
batchesBatchGet[]Configured BatchGet objects
Returns
ExecuteBatchGetAsync(BatchGet[], CancellationToken)
Issues a batch-get request with multiple batches.
Results are stored in the individual batches.
public Task ExecuteBatchGetAsync(BatchGet[] batches, CancellationToken cancellationToken = default)
Parameters
batchesBatchGet[]Configured BatchGet objects
cancellationTokenCancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
ExecuteBatchWriteAsync(BatchWrite[], CancellationToken)
Issues a batch-write request with multiple batches.
public Task ExecuteBatchWriteAsync(BatchWrite[] batches, CancellationToken cancellationToken = default)
Parameters
batchesBatchWrite[]Configured BatchWrite objects
cancellationTokenCancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
~DynamoDBContext()
The destructor for the client class.
protected ~DynamoDBContext()
FromDocument<T>(Document)
Deserializes a document to an instance of type T.
public T FromDocument<T>(Document document)
Parameters
documentDocumentDocument with properties to use.
Returns
- T
Object of type T, populated with properties from the document.
Type Parameters
TType to populate.
FromDocument<T>(Document, DynamoDBOperationConfig)
Deserializes a document to an instance of type T.
public T FromDocument<T>(Document document, DynamoDBOperationConfig operationConfig)
Parameters
documentDocumentDocument with properties to use.
operationConfigDynamoDBOperationConfigConfig object which can be used to override the table used.
Returns
- T
Object of type T, populated with properties from the document.
Type Parameters
TType to populate.
FromDocuments<T>(IEnumerable<Document>)
Deserializes a collections of documents to a collection of instances of type T.
public IEnumerable<T> FromDocuments<T>(IEnumerable<Document> documents)
Parameters
documentsIEnumerable<Document>Documents to deserialize.
Returns
- IEnumerable<T>
Collection of items of type T, each populated with properties from a corresponding document.
Type Parameters
TType to populate.
FromDocuments<T>(IEnumerable<Document>, DynamoDBOperationConfig)
Deserializes a collections of documents to a collection of instances of type T.
public IEnumerable<T> FromDocuments<T>(IEnumerable<Document> documents, DynamoDBOperationConfig operationConfig)
Parameters
documentsIEnumerable<Document>Documents to deserialize.
operationConfigDynamoDBOperationConfigConfig object which can be used to override the table used.
Returns
- IEnumerable<T>
Collection of items of type T, each populated with properties from a corresponding document.
Type Parameters
TType to populate.
FromQueryAsync<T>(QueryOperationConfig, DynamoDBOperationConfig)
Configures an async Query operation against DynamoDB, finding items that match the specified conditions.
public AsyncSearch<T> FromQueryAsync<T>(QueryOperationConfig queryConfig, DynamoDBOperationConfig operationConfig = null)
Parameters
queryConfigQueryOperationConfigQuery request object.
operationConfigDynamoDBOperationConfigConfig object which can be used to override the table used.
Returns
- AsyncSearch<T>
AsyncSearch which can be used to retrieve DynamoDB data.
Type Parameters
TType of object.
FromScanAsync<T>(ScanOperationConfig, DynamoDBOperationConfig)
Configures an async Scan operation against DynamoDB, finding items that match the specified conditions.
public AsyncSearch<T> FromScanAsync<T>(ScanOperationConfig scanConfig, DynamoDBOperationConfig operationConfig = null)
Parameters
scanConfigScanOperationConfigScan request object.
operationConfigDynamoDBOperationConfigConfig object which can be used to override the table used.
Returns
- AsyncSearch<T>
AsyncSearch which can be used to retrieve DynamoDB data.
Type Parameters
TType of object.
GetTargetTable<T>(DynamoDBOperationConfig)
Retrieves the target table for the specified type
public Table GetTargetTable<T>(DynamoDBOperationConfig operationConfig = null)
Parameters
operationConfigDynamoDBOperationConfig
Returns
- Table
Table object
Type Parameters
TType to retrieve table for
LoadAsync<T>(object, DynamoDBOperationConfig, CancellationToken)
Initiates the asynchronous execution of the Load operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Load
public Task<T> LoadAsync<T>(object hashKey, DynamoDBOperationConfig operationConfig, CancellationToken cancellationToken = default)
Parameters
hashKeyobjectHash key element of the target item.
operationConfigDynamoDBOperationConfigOverriding configuration.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task<T>
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType to populate.
LoadAsync<T>(object, object, DynamoDBOperationConfig, CancellationToken)
Initiates the asynchronous execution of the Load operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Load
public Task<T> LoadAsync<T>(object hashKey, object rangeKey, DynamoDBOperationConfig operationConfig, CancellationToken cancellationToken = default)
Parameters
hashKeyobjectHash key element of the target item.
rangeKeyobjectRange key element of the target item.
operationConfigDynamoDBOperationConfigOverriding configuration.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task<T>
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType to populate.
LoadAsync<T>(object, object, CancellationToken)
Initiates the asynchronous execution of the Load operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Load
public Task<T> LoadAsync<T>(object hashKey, object rangeKey, CancellationToken cancellationToken = default)
Parameters
hashKeyobjectHash key element of the target item.
rangeKeyobjectRange key element of the target item.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task<T>
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType to populate.
LoadAsync<T>(object, CancellationToken)
Initiates the asynchronous execution of the Load operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Load
public Task<T> LoadAsync<T>(object hashKey, CancellationToken cancellationToken = default)
Parameters
hashKeyobjectHash key element of the target item.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task<T>
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType to populate.
LoadAsync<T>(T, DynamoDBOperationConfig, CancellationToken)
Initiates the asynchronous execution of the Load operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Load
public Task<T> LoadAsync<T>(T keyObject, DynamoDBOperationConfig operationConfig, CancellationToken cancellationToken = default)
Parameters
keyObjectTKey of the target item.
operationConfigDynamoDBOperationConfigOverriding configuration.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task<T>
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType to populate.
LoadAsync<T>(T, CancellationToken)
Initiates the asynchronous execution of the Load operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Load
public Task<T> LoadAsync<T>(T keyObject, CancellationToken cancellationToken = default)
Parameters
keyObjectTKey of the target item.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task<T>
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType to populate.
QueryAsync<T>(object, DynamoDBOperationConfig)
Configures an async Query operation against DynamoDB, finding items that match the specified hash primary key.
public AsyncSearch<T> QueryAsync<T>(object hashKeyValue, DynamoDBOperationConfig operationConfig = null)
Parameters
hashKeyValueobjectHash key of the items to query.
operationConfigDynamoDBOperationConfigConfig object which can be used to override the table used.
Returns
- AsyncSearch<T>
AsyncSearch which can be used to retrieve DynamoDB data.
Type Parameters
TType of object.
QueryAsync<T>(object, QueryOperator, IEnumerable<object>, DynamoDBOperationConfig)
Configures an async Query operation against DynamoDB, finding items that match the specified range element condition for a hash-and-range primary key.
public AsyncSearch<T> QueryAsync<T>(object hashKeyValue, QueryOperator op, IEnumerable<object> values, DynamoDBOperationConfig operationConfig = null)
Parameters
hashKeyValueobjectHash key of the items to query.
opQueryOperatorOperation of the condition.
valuesIEnumerable<object>Value(s) of the condition. For all operations except QueryOperator.Between, values should be one value. For QueryOperator.Between, values should be two values.
operationConfigDynamoDBOperationConfigConfig object which can be used to override the table used.
Returns
- AsyncSearch<T>
AsyncSearch which can be used to retrieve DynamoDB data.
Type Parameters
TType of object.
SaveAsync<T>(T, DynamoDBOperationConfig, CancellationToken)
Initiates the asynchronous execution of the Save operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Save
public Task SaveAsync<T>(T value, DynamoDBOperationConfig operationConfig, CancellationToken cancellationToken = default)
Parameters
valueTObject to save.
operationConfigDynamoDBOperationConfigOverriding configuration.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType to save as.
SaveAsync<T>(T, CancellationToken)
Initiates the asynchronous execution of the Save operation. Amazon.DynamoDBv2.DataModel.DynamoDBContext.Save
public Task SaveAsync<T>(T value, CancellationToken cancellationToken = default)
Parameters
valueTObject to save.
cancellationTokenCancellationTokenToken which can be used to cancel the task.
Returns
- Task
A Task that can be used to poll or wait for results, or both.
Type Parameters
TType to save as.
ScanAsync<T>(IEnumerable<ScanCondition>, DynamoDBOperationConfig)
Configures an async Scan operation against DynamoDB, finding items that match the specified conditions.
public AsyncSearch<T> ScanAsync<T>(IEnumerable<ScanCondition> conditions, DynamoDBOperationConfig operationConfig = null)
Parameters
conditionsIEnumerable<ScanCondition>Conditions that the results should meet.
operationConfigDynamoDBOperationConfigConfig object which can be used to override that table used.
Returns
- AsyncSearch<T>
AsyncSearch which can be used to retrieve DynamoDB data.
Type Parameters
TType of object.
ToDocument<T>(T)
Serializes an object to a Document.
public Document ToDocument<T>(T value)
Parameters
valueTObject to serialize.
Returns
- Document
Document with attributes populated from object.
Type Parameters
TType to serialize as.
ToDocument<T>(T, DynamoDBOperationConfig)
Serializes an object to a Document.
public Document ToDocument<T>(T value, DynamoDBOperationConfig operationConfig)
Parameters
valueTObject to serialize.
operationConfigDynamoDBOperationConfigConfig object which can be used to override the table used.
Returns
- Document
Document with attributes populated from object.
Type Parameters
TType to serialize as.