-
Notifications
You must be signed in to change notification settings - Fork 3
Base Repository Classes
(under construction) EDennis.AspNetCore.Base provides four base repository classes, which cross writeability with temporality. Two of the base repos are writeable and two are readonly. Two of the base repos have temporal support (write to history tables) and two do not have temporal support. The table below summarizes the four repo types.

WriteableRepo provides methods for reading from and writing to current-record tables.
WriteableRepo has two type parameters:
| Type Parameter | Constraints |
|---|---|
TEntity |
TEntity is a class with a default constructor and implements IHasSysUser |
TContext |
TContext extends Microsoft.EntityFrameworkCore.DbContext |
The WriteableRepo constructor accepts two arguments:
- TContext -- any subclass of Entity Framework Core's DbContext
- ScopeProperties -- a class designed to communicate the user name and other data (e.g., headers) from one or more MVC filters to the repo. This class should be dependency injected with a scoped lifetime.
public WriteableRepo(TContext context, ScopeProperties scopeProperties)WriteableRepo provides basic CRUD methods, which automatically save data to the database when needed.
| Method | Description |
|---|---|
public virtual TEntity GetById(params object[] keyValues) |
Retrieve a record by the primary key |
public virtual async Task<TEntity> GetByIdAsync(params object[] keyValues) |
Asynchronous version of GetById |
public virtual bool Exists(params object[] keyValues) |
Determine if a record with the provided key exists |
public virtual async Task<bool> ExistsAsync(params object[] keyValues) |
Asynchronous version of Exists |
public virtual TEntity Create(TEntity entity) |
Inserts a new TEntity record into the database |
public virtual async Task<TEntity> CreateAsync(TEntity entity) |
Asynchronous version of Create |
public virtual TEntity Update(TEntity entity, params object[] keyValues) |
Replaces the TEntity record with data from the provided object |
public virtual async Task<TEntity> UpdateAsync(TEntity entity, params object[] keyValues) |
Asynchronous version of Update |
public virtual void Delete(params object[] keyValues) |
Delete the record with the provided primary key |
public virtual async Task DeleteAsync(params object[] keyValues) |
Asynchronous version of Delete |
WriteableTemporalRepo extends WriteableRepo and provides some additional methods related to temporal operations.
WriteableTemporalRepo has three type parameters:
| Type Parameter | Constraints |
|---|---|
TEntity |
TEntity is a class with a default constructor and implements IEFCoreTemporalModel |
TContext |
TContext extends Microsoft.EntityFrameworkCore.DbContext |
THistoryContext |
THistoryContext extends Microsoft.EntityFrameworkCore.DbContext |
The WriteableTemporalRepo constructor accepts three arguments:
- TContext -- any subclass of Entity Framework Core's DbContext. This is the current-records context.
- TContext -- any subclass of Entity Framework Core's DbContext. This is the history-records context.
- ScopeProperties -- a class designed to communicate the user name and other data (e.g., headers) from one or more MVC filters to the repo. This class should be dependency injected with a scoped lifetime.
public WriteableTemporalRepo(TContext context, ScopeProperties scopeProperties)WriteableTemporalRepo provides all of the CRUD methods from WriteableRepo, as well as some temporal-related methods.
| Method | Description |
|---|---|
public virtual bool WriteUpdate(TEntity next, TEntity current) |
Allows configuration of when records are written to the history table during updates. The default is always. |
public virtual bool WriteDelete(TEntity current) |
Allows configuration of when records are written to the history table during deletes. The default is always. |
Development Support
- Temporal Entities
- Base Repository Classes
- Base API Controller Classes
- ApiClient and SecureApiClient
- Security Utilities
- IServiceCollection Extension Methods
- HttpClient Extension Methods
- ScopeProperties
- MigrationsExtensionsDbContextDesignTimeFactory
Testing Support
- API Launcher
- Testing Strategy and Infrastructure
- Xunit Support Classes
- Testing Security Utilities
Related Projects