Show / Hide Table of Contents

Class CosmosOwnedItemRepository<T>

Provides repository implementation for items that are owned by a user.

Inheritance
object
CosmosRepository<T>
CosmosOwnedItemRepository<T>
CosmosDbParentedItemRepository<T>
Implements
IOwnedItemRepository<T>
IRepository<T>
Inherited Members
CosmosRepository<T>.DiscriminatorValue
CosmosRepository<T>.Logger
CosmosRepository<T>._Options
CosmosRepository<T>.GetContainer()
CosmosRepository<T>.DeleteAsync(string)
CosmosRepository<T>.GetAllAsync()
CosmosRepository<T>.GetResults(IQueryable<T>, string, PartitionKey)
CosmosRepository<T>.GetResults(FeedIterator<T>, string)
CosmosRepository<T>.GetQueryDescription(string)
CosmosRepository<T>.GetQueryDescription(string, string)
CosmosRepository<T>.IsCrossPartitionQuery(CosmosDiagnostics)
CosmosRepository<T>.GetByIdAsync(string)
CosmosRepository<T>.Initialize()
CosmosRepository<T>.SaveAsync(T)
CosmosRepository<T>.BatchSize
CosmosRepository<T>.SaveAsync(IList<T>)
CosmosRepository<T>.SaveBatchAsync(int, int, T[])
CosmosRepository<T>.AfterSaveBatch(TransactionalBatchResponse, T[], int, int)
CosmosRepository<T>.BeforeSaveBatch(TransactionalBatch, T[], int, int)
CosmosRepository<T>.GetPartitionKey(T)
CosmosRepository<T>.GetPartitionKey(string, string)
CosmosRepository<T>.GetQueryable(string)
CosmosRepository<T>.GetQueryable(string, string)
CosmosRepository<T>.GetQueryable()
CosmosRepository<T>.GetPagedAsync(int, string)
CosmosRepository<T>.GetPagedAsync(string, int, string)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Benday.CosmosDb.Repositories
Assembly: Benday.CosmosDb.dll
Syntax
public class CosmosOwnedItemRepository<T> : CosmosRepository<T>, IOwnedItemRepository<T>, IRepository<T> where T : class, IOwnedItem, new()
Type Parameters
Name Description
T

Domain model type managed by the repository

Constructors

| Edit this page View Source

CosmosOwnedItemRepository(IOptions<CosmosRepositoryOptions<T>>, CosmosClient, ILogger<CosmosOwnedItemRepository<T>>)

Provides repository implementation for items that are owned by a user.

Declaration
public CosmosOwnedItemRepository(IOptions<CosmosRepositoryOptions<T>> options, CosmosClient client, ILogger<CosmosOwnedItemRepository<T>> logger)
Parameters
Type Name Description
IOptions<CosmosRepositoryOptions<T>> options

Configuration options for the repository

CosmosClient client

Instance of the cosmos db client. NOTE: for performance reasons, this should probably be a singleton in the application.

ILogger<CosmosOwnedItemRepository<T>> logger

Properties

| Edit this page View Source

BulkMaxConcurrency

Maximum concurrent operations for bulk operations. Override in derived class if needed.

Declaration
protected virtual int BulkMaxConcurrency { get; }
Property Value
Type Description
int
| Edit this page View Source

BulkMaxRetries

Maximum retry attempts for throttled requests. Override in derived class if needed.

Declaration
protected virtual int BulkMaxRetries { get; }
Property Value
Type Description
int

Methods

| Edit this page View Source

DeleteAllByOwnerIdAsync(string, int, int, CancellationToken)

Deletes all items for the specified owner with configurable throttling and retry logic.

Declaration
public Task DeleteAllByOwnerIdAsync(string ownerId, int maxConcurrency, int maxRetries, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string ownerId

Owner id for the items to delete

int maxConcurrency

Maximum number of concurrent delete operations

int maxRetries

Maximum number of retry attempts for throttled requests

CancellationToken cancellationToken

Cancellation token

Returns
Type Description
Task
| Edit this page View Source

DeleteAllByOwnerIdAsync(string, CancellationToken)

Deletes all items for the specified owner with throttling and retry logic.

Declaration
public Task DeleteAllByOwnerIdAsync(string ownerId, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string ownerId

Owner id for the items to delete

CancellationToken cancellationToken

Cancellation token

Returns
Type Description
Task
| Edit this page View Source

DeleteAsync(T)

Delete an item from the repository.

Declaration
public Task DeleteAsync(T itemToDelete)
Parameters
Type Name Description
T itemToDelete
Returns
Type Description
Task
| Edit this page View Source

DeleteWithRetryAsync(T, int, CancellationToken)

Deletes a single item with retry logic for throttled requests (HTTP 429).

Declaration
protected Task DeleteWithRetryAsync(T item, int maxRetries, CancellationToken cancellationToken = default)
Parameters
Type Name Description
T item

Item to delete

int maxRetries

Maximum number of retry attempts

CancellationToken cancellationToken

Cancellation token

Returns
Type Description
Task
| Edit this page View Source

GetAllAsync(string)

Get all items in the repository that have the specified owner id. Default implementation will return items in descending order by timestamp.

Declaration
public Task<IEnumerable<T>> GetAllAsync(string ownerId)
Parameters
Type Name Description
string ownerId

Owner id

Returns
Type Description
Task<IEnumerable<T>>
| Edit this page View Source

GetByIdAsync(string, string)

Gets an entity by its id and owner id.

Declaration
public virtual Task<T?> GetByIdAsync(string ownerId, string id)
Parameters
Type Name Description
string ownerId
string id
Returns
Type Description
Task<T>

Matching item or null if not found

| Edit this page View Source

SaveAllAsync(IEnumerable<T>, int, int, CancellationToken)

Saves multiple items with configurable throttling and retry logic.

Declaration
public Task SaveAllAsync(IEnumerable<T> items, int maxConcurrency, int maxRetries, CancellationToken cancellationToken = default)
Parameters
Type Name Description
IEnumerable<T> items

Items to save

int maxConcurrency

Maximum number of concurrent save operations

int maxRetries

Maximum number of retry attempts for throttled requests

CancellationToken cancellationToken

Cancellation token

Returns
Type Description
Task
| Edit this page View Source

SaveAllAsync(IEnumerable<T>, CancellationToken)

Saves multiple items with throttling and retry logic.

Declaration
public Task SaveAllAsync(IEnumerable<T> items, CancellationToken cancellationToken = default)
Parameters
Type Name Description
IEnumerable<T> items

Items to save

CancellationToken cancellationToken

Cancellation token

Returns
Type Description
Task
| Edit this page View Source

SaveWithRetryAsync(T, int, CancellationToken)

Saves a single item with retry logic for throttled requests (HTTP 429).

Declaration
protected Task SaveWithRetryAsync(T item, int maxRetries, CancellationToken cancellationToken = default)
Parameters
Type Name Description
T item

Item to save

int maxRetries

Maximum number of retry attempts

CancellationToken cancellationToken

Cancellation token

Returns
Type Description
Task

Implements

IOwnedItemRepository<T>
IRepository<T>
  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com