Interface IRepository<T>
Interface for the basic operations of a Cosmos DB repository.
Namespace: Benday.CosmosDb.Repositories
Assembly: Benday.CosmosDb.dll
Syntax
public interface IRepository<T> where T : class
Type Parameters
| Name | Description |
|---|---|
| T | Domain model type that is managed by this repository |
Methods
| Edit this page View SourceDeleteAsync(string)
Delete the entity from the repository.
Declaration
Task DeleteAsync(string id)
Parameters
| Type | Name | Description |
|---|---|---|
| string | id | Id for the entity to delete |
Returns
| Type | Description |
|---|---|
| Task |
GetAllAsync()
Gets all entities in the repository.
Declaration
Task<IEnumerable<T>> GetAllAsync()
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<T>> |
GetByIdAsync(string)
Gets an entity by its id.
Declaration
Task<T?> GetByIdAsync(string id)
Parameters
| Type | Name | Description |
|---|---|---|
| string | id | Id of the entity |
Returns
| Type | Description |
|---|---|
| Task<T> | The matching entity or null if not found |
GetPagedAsync(int, string?)
Gets a page of results with continuation support.
Declaration
Task<PagedResults<T>> GetPagedAsync(int pageSize = 100, string? continuationToken = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | pageSize | Maximum number of items to return |
| string | continuationToken | Continuation token from previous query (null for first page) |
Returns
| Type | Description |
|---|---|
| Task<PagedResults<T>> | A page of results with continuation information |
SaveAsync(IList<T>)
Save a list of entities to the repository. Perform an insert if the entity does not exist, otherwise perform an update.
Declaration
Task SaveAsync(IList<T> items)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<T> | items | Entities to save |
Returns
| Type | Description |
|---|---|
| Task |
SaveAsync(T)
Save the entity to the repository. Perform an insert if the entity does not exist, otherwise perform an update.
Declaration
Task<T> SaveAsync(T entity)
Parameters
| Type | Name | Description |
|---|---|---|
| T | entity | Entity to save |
Returns
| Type | Description |
|---|---|
| Task<T> | The saved entity |