Innovt Platform
Search Results for

    Show / Hide Table of Contents

    Class Repository

    Base repository class for interacting with AWS DynamoDB tables.

    Inheritance
    object
    AwsBaseService
    Repository
    Implements
    ITableRepository
    IDisposable
    Inherited Members
    AwsBaseService.Configuration
    AwsBaseService.ExponentialBackoffInSeconds
    AwsBaseService.Logger
    AwsBaseService.Dispose()
    AwsBaseService.GetServiceRegionEndPoint()
    AwsBaseService.CreateService<T>()
    AwsBaseService.CreateDefaultRetryPolicy()
    AwsBaseService.CreateRetryAsyncPolicy<T>()
    AwsBaseService.CreateRetryAsyncPolicy<T, T1>()
    AwsBaseService.CreateRetryAsyncPolicy<T, T1, T2>()
    AwsBaseService.CreateRetryAsyncPolicy<T, T1, T2, T3>()
    AwsBaseService.CreateRetryAsyncPolicy<T, T1, T2, T3, T4>()
    AwsBaseService.CreateCircuitBreaker<T, T1>()
    AwsBaseService.Dispose(bool)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Innovt.Cloud.AWS.Dynamo
    Assembly: Innovt.Cloud.AWS.Dynamo.dll
    Syntax
    public abstract class Repository : AwsBaseService, ITableRepository, IDisposable

    Constructors

    | Edit this page View Source

    Repository(ILogger, IAwsConfiguration)

    Initializes a new instance of the Repository class.

    Declaration
    protected Repository(ILogger logger, IAwsConfiguration configuration)
    Parameters
    Type Name Description
    ILogger logger

    The logger.

    IAwsConfiguration configuration

    AWS configuration.

    | Edit this page View Source

    Repository(ILogger, IAwsConfiguration, DynamoContext)

    Initializes a new instance of the Repository class using a context map.

    Declaration
    protected Repository(ILogger logger, IAwsConfiguration configuration, DynamoContext context)
    Parameters
    Type Name Description
    ILogger logger
    IAwsConfiguration configuration
    DynamoContext context
    Exceptions
    Type Condition
    ArgumentNullException
    | Edit this page View Source

    Repository(ILogger, IAwsConfiguration, string)

    Initializes a new instance of the Repository class.

    Declaration
    protected Repository(ILogger logger, IAwsConfiguration configuration, string region)
    Parameters
    Type Name Description
    ILogger logger

    The logger.

    IAwsConfiguration configuration

    AWS configuration.

    string region

    The AWS region.

    Methods

    | Edit this page View Source

    AddAsync<T>(T, CancellationToken)

    Asynchronously adds a single item to the repository.

    Declaration
    public Task AddAsync<T>(T message, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    T message

    The item to add.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task

    A task representing the asynchronous add operation.

    Type Parameters
    Name Description
    T

    The type of item to add.

    | Edit this page View Source

    AddRangeAsync<T>(ICollection<T>, CancellationToken)

    Adds a list of items to the DynamoDB table.

    Declaration
    public Task AddRangeAsync<T>(ICollection<T> messages, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    ICollection<T> messages

    The list of items to add.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task
    Type Parameters
    Name Description
    T

    The type of items to add.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if the messages parameter is null.

    | Edit this page View Source

    BatchGetItem<T>(BatchGetItemRequest, CancellationToken)

    Gets a batch of items from the DynamoDB table based on the specified batch get item request.

    Declaration
    public Task<List<T>> BatchGetItem<T>(BatchGetItemRequest batchGetItemRequest, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    BatchGetItemRequest batchGetItemRequest

    The batch get item request.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<List<T>>

    The list of items retrieved.

    Type Parameters
    Name Description
    T

    The type of items to get.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when the batch get item request is null.

    | Edit this page View Source

    BatchWriteItem(BatchWriteItemRequest, CancellationToken)

    Writes a batch of items to the DynamoDB table based on the specified batch write item request.

    Declaration
    public Task<BatchWriteItemResponse> BatchWriteItem(BatchWriteItemRequest batchWriteItemRequest, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    BatchWriteItemRequest batchWriteItemRequest

    The batch write item request.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<BatchWriteItemResponse>

    The response indicating the result of the batch write operation.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when the batch write item request is null.

    | Edit this page View Source

    CreateDefaultRetryAsyncPolicy()

    Creates the default asynchronous retry policy for handling exceptions during operations.

    Declaration
    protected override AsyncRetryPolicy CreateDefaultRetryAsyncPolicy()
    Returns
    Type Description
    AsyncRetryPolicy

    The asynchronous retry policy instance.

    Overrides
    AwsBaseService.CreateDefaultRetryAsyncPolicy()
    | Edit this page View Source

    CreateTransactionWriteItem<T>(T, TransactionWriteOperationType)

    Create a transaction write item based on the instance.

    Declaration
    public TransactionWriteItem CreateTransactionWriteItem<T>(T instance, TransactionWriteOperationType operationType = TransactionWriteOperationType.Put) where T : class, new()
    Parameters
    Type Name Description
    T instance

    A mapped instance with context.

    TransactionWriteOperationType operationType

    The operation that you want to perform.

    Returns
    Type Description
    TransactionWriteItem

    A incomplete transaction write item with properties mapped.

    Type Parameters
    Name Description
    T

    A typed mapped entity

    | Edit this page View Source

    DeleteAsync<T>(object, string, CancellationToken)

    Asynchronously deletes an item using its identifier and optional range key.

    Declaration
    public Task DeleteAsync<T>(object id, string rangeKey = null, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    object id

    The identifier of the item.

    string rangeKey

    The range key for the item (optional).

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task

    A task representing the asynchronous delete operation.

    Type Parameters
    Name Description
    T

    The type of item to delete.

    | Edit this page View Source

    DeleteAsync<T>(T, CancellationToken)

    Asynchronously deletes an item using its value.

    Declaration
    public Task DeleteAsync<T>(T message, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    T message

    The item to delete.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task

    A task representing the asynchronous delete operation.

    Type Parameters
    Name Description
    T

    The type of item to delete.

    | Edit this page View Source

    DeleteRangeAsync<T>(ICollection<T>, CancellationToken)

    Asynchronously a list of item that are from the same type.

    Declaration
    public Task DeleteRangeAsync<T>(ICollection<T> messages, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    ICollection<T> messages
    CancellationToken cancellationToken
    Returns
    Type Description
    Task
    Type Parameters
    Name Description
    T
    | Edit this page View Source

    DisposeServices()

    Disposes the DynamoDB context and AmazonDynamoDBClient resources.

    Declaration
    protected override void DisposeServices()
    Overrides
    AwsBaseService.DisposeServices()
    | Edit this page View Source

    ExecuteStatementAsync<T>(ExecuteSqlStatementRequest, CancellationToken)

    Executes a SQL statement asynchronously and returns the response containing items of type T.

    Declaration
    public Task<ExecuteSqlStatementResponse<T>> ExecuteStatementAsync<T>(ExecuteSqlStatementRequest sqlStatementRequest, CancellationToken cancellationToken = default) where T : class, new()
    Parameters
    Type Name Description
    ExecuteSqlStatementRequest sqlStatementRequest

    The SQL statement request.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<ExecuteSqlStatementResponse<T>>

    The response containing items of type T.

    Type Parameters
    Name Description
    T

    The type of items to be returned.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when the SQL statement request is null.

    | Edit this page View Source

    GetByIdAsync<T>(object, string?, CancellationToken)

    Asynchronously retrieves an item by its identifier.

    Declaration
    public Task<T?> GetByIdAsync<T>(object id, string? rangeKey = null, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    object id

    The identifier of the item.

    string rangeKey

    The range key for the item (optional).

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<T>

    An item of type T if found; otherwise, null.

    Type Parameters
    Name Description
    T

    The type of item to retrieve.

    | Edit this page View Source

    QueryAsync<T>(QueryRequest, CancellationToken)

    Queries the DynamoDB table using a query request and returns a list of items.

    Declaration
    public Task<IList<T>> QueryAsync<T>(QueryRequest request, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    QueryRequest request

    The query request.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<IList<T>>

    A list of items based on the query request.

    Type Parameters
    Name Description
    T

    The type of items to query.

    | Edit this page View Source

    QueryAsync<T>(object, CancellationToken)

    Queries the DynamoDB table and returns a list of items with the specified id.

    Declaration
    public Task<IList<T>> QueryAsync<T>(object id, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    object id

    The id to query.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<IList<T>>

    A list of items with the specified id.

    Type Parameters
    Name Description
    T

    The type of items to query.

    | Edit this page View Source

    QueryFirstAsync<T>(object, CancellationToken)

    Asynchronously queries and retrieves the first item of type T by its identifier.

    Declaration
    public Task<T?> QueryFirstAsync<T>(object id, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    object id

    The identifier of the item.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<T>

    An item of type T if found; otherwise, null.

    Type Parameters
    Name Description
    T

    The type of item to retrieve.

    | Edit this page View Source

    QueryFirstOrDefaultAsync<T>(QueryRequest, CancellationToken)

    Queries the DynamoDB table and returns the first or default item based on the query request.

    Declaration
    public Task<T?> QueryFirstOrDefaultAsync<T>(QueryRequest request, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    QueryRequest request

    The query request.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<T>

    The first or default item based on the query request.

    Type Parameters
    Name Description
    T

    The type of item to query.

    | Edit this page View Source

    QueryMultipleAsync<T, TResult1, TResult2>(QueryRequest, string, CancellationToken)

    Queries the DynamoDB table using a query request and splits the results into two types based on a key.

    Declaration
    public Task<(IList<TResult1> first, IList<TResult2> second)> QueryMultipleAsync<T, TResult1, TResult2>(QueryRequest request, string splitBy, CancellationToken cancellationToken = default) where T : class where TResult1 : class where TResult2 : class
    Parameters
    Type Name Description
    QueryRequest request

    The query request.

    string splitBy

    The key to split the results.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<(IList<TResult1> first, IList<TResult2> second)>

    Tuple containing lists of items split based on the specified key.

    Type Parameters
    Name Description
    T

    The type of items to query.

    TResult1

    The first type to split the results into.

    TResult2

    The second type to split the results into.

    | Edit this page View Source

    QueryMultipleAsync<T, TResult1, TResult2, TResult3>(QueryRequest, string[], CancellationToken)

    Queries the DynamoDB table using a query request and splits the results into three types based on specified keys.

    Declaration
    public Task<(IList<TResult1> first, IList<TResult2> second, IList<TResult3> third)> QueryMultipleAsync<T, TResult1, TResult2, TResult3>(QueryRequest request, string[] splitBy, CancellationToken cancellationToken = default) where T : class where TResult1 : class where TResult2 : class where TResult3 : class
    Parameters
    Type Name Description
    QueryRequest request

    The query request.

    string[] splitBy

    The keys to split the results.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<(IList<TResult1> first, IList<TResult2> second, IList<TResult3> third)>

    Tuple containing lists of items split based on the specified keys.

    Type Parameters
    Name Description
    T

    The type of items to query.

    TResult1

    The first type to split the results into.

    TResult2

    The second type to split the results into.

    TResult3

    The third type to split the results into.

    | Edit this page View Source

    QueryMultipleAsync<T, TResult1, TResult2, TResult3, TResult4>(QueryRequest, string[], CancellationToken)

    Queries the DynamoDB table using a query request and splits the results into four types based on specified keys.

    Declaration
    public Task<(IList<TResult1> first, IList<TResult2> second, IList<TResult3> third, IList<TResult4> fourth)> QueryMultipleAsync<T, TResult1, TResult2, TResult3, TResult4>(QueryRequest request, string[] splitBy, CancellationToken cancellationToken = default) where T : class where TResult1 : class where TResult2 : class where TResult3 : class where TResult4 : class
    Parameters
    Type Name Description
    QueryRequest request

    The query request.

    string[] splitBy

    The keys to split the results.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<(IList<TResult1> first, IList<TResult2> second, IList<TResult3> third, IList<TResult4> fourth)>

    Tuple containing lists of items split based on the specified keys.

    Type Parameters
    Name Description
    T

    The type of items to query.

    TResult1

    The first type to split the results into.

    TResult2

    The second type to split the results into.

    TResult3

    The third type to split the results into.

    TResult4

    The fourth type to split the results into.

    | Edit this page View Source

    QueryMultipleAsync<T, TResult1, TResult2, TResult3, TResult4, TResult5>(QueryRequest, string[], CancellationToken)

    Queries the DynamoDB table using a query request and splits the results into five types based on specified keys.

    Declaration
    public Task<(IList<TResult1> first, IList<TResult2> second, IList<TResult3> third, IList<TResult4> fourth, IList<TResult5> fifth)> QueryMultipleAsync<T, TResult1, TResult2, TResult3, TResult4, TResult5>(QueryRequest request, string[] splitBy, CancellationToken cancellationToken = default) where T : class where TResult1 : class where TResult2 : class where TResult3 : class where TResult4 : class where TResult5 : class
    Parameters
    Type Name Description
    QueryRequest request

    The query request.

    string[] splitBy

    The keys to split the results.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<(IList<TResult1> first, IList<TResult2> second, IList<TResult3> third, IList<TResult4> fourth, IList<TResult5> fifth)>

    Tuple containing lists of items split based on the specified keys.

    Type Parameters
    Name Description
    T

    The type of items to query.

    TResult1

    The first type to split the results into.

    TResult2

    The second type to split the results into.

    TResult3

    The third type to split the results into.

    TResult4

    The fourth type to split the results into.

    TResult5

    The fifth type to split the results into.

    | Edit this page View Source

    QueryPaginatedByAsync<T>(QueryRequest, CancellationToken)

    Queries the DynamoDB table using a query request and returns a paginated collection of items.

    Declaration
    public Task<PagedCollection<T>> QueryPaginatedByAsync<T>(QueryRequest request, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    QueryRequest request

    The query request.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<PagedCollection<T>>

    A paginated collection of items based on the query request.

    Type Parameters
    Name Description
    T

    The type of items to query.

    | Edit this page View Source

    ScanAsync<T>(ScanRequest, CancellationToken)

    Scans the DynamoDB table based on the specified scan request.

    Declaration
    public Task<IList<T>> ScanAsync<T>(ScanRequest request, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    ScanRequest request

    The scan request.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<IList<T>>

    The list of scanned items.

    Type Parameters
    Name Description
    T

    The type of items to scan.

    | Edit this page View Source

    ScanPaginatedByAsync<T>(ScanRequest, CancellationToken)

    Scans the DynamoDB table based on the specified scan request and returns a paginated collection of items.

    Declaration
    public Task<PagedCollection<T>> ScanPaginatedByAsync<T>(ScanRequest request, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    ScanRequest request

    The scan request.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task<PagedCollection<T>>

    A paginated collection of items based on the scan request.

    Type Parameters
    Name Description
    T

    The type of items to scan.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when the request is null.

    | Edit this page View Source

    TransactWriteItemsAsync(TransactionWriteRequest, CancellationToken)

    Writes a batch of transactional write items to the DynamoDB table.

    Declaration
    public Task TransactWriteItemsAsync(TransactionWriteRequest request, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    TransactionWriteRequest request

    The transaction write request.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task

    Task representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when the request is null.

    BusinessException

    Thrown when the number of transactItems is invalid.

    | Edit this page View Source

    UpdateAsync(string, Dictionary<string, AttributeValue>, Dictionary<string, AttributeValueUpdate>, CancellationToken)

    Updates an item in the DynamoDB table based on the provided parameters.

    Declaration
    protected Task UpdateAsync(string tableName, Dictionary<string, AttributeValue> key, Dictionary<string, AttributeValueUpdate> attributeUpdates, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string tableName

    The name of the DynamoDB table.

    Dictionary<string, AttributeValue> key

    The key of the item to update.

    Dictionary<string, AttributeValueUpdate> attributeUpdates

    The attribute updates for the item.

    CancellationToken cancellationToken

    Cancellation token to cancel the operation.

    Returns
    Type Description
    Task

    Task representing the asynchronous update operation.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when key or attributeUpdates is null.

    | Edit this page View Source

    UpdateAsync<T>(T, CancellationToken)

    This method will perform an update operation on the table. The operation is based on the primary key and type is PUT.

    Declaration
    public Task<T> UpdateAsync<T>(T instance, CancellationToken cancellationToken = default) where T : class, new()
    Parameters
    Type Name Description
    T instance

    The instance that you want to update

    CancellationToken cancellationToken

    A cancellation token.

    Returns
    Type Description
    Task<T>
    Type Parameters
    Name Description
    T

    The instance updated.

    Exceptions
    Type Condition
    ArgumentNullException

    Implements

    ITableRepository
    IDisposable

    Extension Methods

    Extensions.IsNull(object)
    Extensions.ToStringOrDefault(object)
    SimpleMapper.MapTo<T1>(object)
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX