Skip to content

kritikos-io/Configuration.Persistence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Configuration.Persistence

Build Status codecov Coverage Status Quality Gate Status License GitHub language count GitHub top language

Starting point and useful extensions to handle database persistence via Entity Framework Core.

Persistence Abstractions

  • IEntity<TKey> marks and groups primary entities in project having a primary key of type TKey
  • IConcurrent provides RowVersion used by Microsoft SQL Server for database concurrency
  • ITimestamped and IAuditable<T> handle audit records and are compatible with provided interceptors

Examples can be found in BasicEntity, ConcurrentEntity and Entity.

Interceptors

A set of pre-transaction interceptors that provide helper functions. Current list includes:

  • AuditSaveChangesInterceptor: provides auditing for create/update events, requires an implementation of IAuditorProvider in order to work
  • ITimeStampSaveChangesInterceptor: populates fields provided by ITimestamped, auditing create and update dates of each record
  • ReadOnlyDbCommandInterceptor: turns a database readonly by supressing all actions in SaveChanges

Services

  • MigrationService<TContext> is an oneshot HostedService that enforces database migration before kestrel starts serving requests.

Extensions

Please refrain from using ChangeTracker extensions, they are considered obsolete and will be removed at some point in the future.

  • EntitiesOfType is a ModelBuilder extension that allows configuring all entities inheriting common interfaces.

Additional Features

Library Kritikos.Configuration.Peristence.IdentityServer contains an ApiAuthorizationDbContext wrapper for Microsoft.AspNetCore.ApiAuthorization.IdentityServer handling the missing overload for IdentityDbContext<TUser,TRole,TKey>.

KritikosConfiguration.Persistence.HealthCheck offers a basic DbContext IHealthCheck for use with ASP .NET Core.

Converters

Use with care, not all converters support every available query execution at database level. Consult the documentation before applying.

  • DirectoryInfo to string
  • FileInfo to string
  • Relative URI to string
  • TimeSpan to number

About

🗃️ Basic abstractions to handle persistence mapping via ORM

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages