Demolite.Db
0.0.3
dotnet add package Demolite.Db --version 0.0.3
NuGet\Install-Package Demolite.Db -Version 0.0.3
<PackageReference Include="Demolite.Db" Version="0.0.3" />
paket add Demolite.Db --version 0.0.3
#r "nuget: Demolite.Db, 0.0.3"
// Install Demolite.Db as a Cake Addin #addin nuget:?package=Demolite.Db&version=0.0.3 // Install Demolite.Db as a Cake Tool #tool nuget:?package=Demolite.Db&version=0.0.3
Demolite.Db
Demolite.Db is a simple database wrapper package utilizing EF Core and Serilog. It is meant to reduce the amount of boilerplate code needed for creating new projects and for handling db operations.
Using this package works as follows:
- Create an abstract repository for your DbContext
public abstract class AbstractMyContextRepository<T>(IDbContextFactory<MyDbContext> contextFactory)
: AbstractBaseRepository<T, MyContext>
where T: class, IHasOperation
{
}
In the context, override the methods for GetContextAsync() and GetContext(). In this example, a context factory is injected, but you can use any method to instantiate your DbContext.
Create a db model which inherits AbstractDbItem, or create your own AbstractDbItem which implements the IDbItem and IHasOperation interface
public class ModelType : AbstractDbItem
- Create an empty interface class for your repository which implements IDbRepository for your model class.
public interface IModelTypeRepository : IDbRepository<ModelType>;
- Implement the interface and inherit from your abstract repository in your model type repository:
public class ModelTypeRepository(IDbContextFactory<MyDbContext> contextFactory)
: AbstractMyContextRepository<ModelType>(contextFactory), IModelTypeRepository
- Now just register the repository in your DI and it is ready to use.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.8)
- Serilog (>= 4.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.