Demolite.Db 0.0.3

dotnet add package Demolite.Db --version 0.0.3                
NuGet\Install-Package Demolite.Db -Version 0.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Demolite.Db" Version="0.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Demolite.Db --version 0.0.3                
#r "nuget: Demolite.Db, 0.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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:

  1. Create an abstract repository for your DbContext
    public abstract class AbstractMyContextRepository<T>(IDbContextFactory<MyDbContext> contextFactory)
        : AbstractBaseRepository<T, MyContext> 
        where T: class, IHasOperation
    {
        
    }
  1. 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.

  2. Create a db model which inherits AbstractDbItem, or create your own AbstractDbItem which implements the IDbItem and IHasOperation interface

    public class ModelType : AbstractDbItem
  1. Create an empty interface class for your repository which implements IDbRepository for your model class.
    public interface IModelTypeRepository : IDbRepository<ModelType>;
  1. Implement the interface and inherit from your abstract repository in your model type repository:
    public class ModelTypeRepository(IDbContextFactory<MyDbContext> contextFactory) 
        : AbstractMyContextRepository<ModelType>(contextFactory), IModelTypeRepository
  1. Now just register the repository in your DI and it is ready to use.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.3 171 9/29/2024
0.0.2 98 9/29/2024