Skip to content

Base Repository Classes

Dennis C. Mitchell edited this page Mar 16, 2019 · 22 revisions

(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.

4 Repo Types Image

WriteableRepo

WriteableRepo provides methods for reading from and writing to current-record tables.

Constructor

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)

Methods

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

(to be continued...)

Clone this wiki locally