Jay.EFCore.UnitOfWork 1.0.5

dotnet add package Jay.EFCore.UnitOfWork --version 1.0.5
                    
NuGet\Install-Package Jay.EFCore.UnitOfWork -Version 1.0.5
                    
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="Jay.EFCore.UnitOfWork" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jay.EFCore.UnitOfWork" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Jay.EFCore.UnitOfWork" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Jay.EFCore.UnitOfWork --version 1.0.5
                    
#r "nuget: Jay.EFCore.UnitOfWork, 1.0.5"
                    
#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.
#:package Jay.EFCore.UnitOfWork@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Jay.EFCore.UnitOfWork&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Jay.EFCore.UnitOfWork&version=1.0.5
                    
Install as a Cake Tool

//===================================================== Jay.EFCore.UnitOfWork

A dynamic repository and UnitOfWork implementation for Entity Framework Core, incorporating IDisposable to enhance the scalability and efficiency of your CRUD operations. Jay.EFCore.UnitOfWork works with EF Core for SQL Server, Azure SQL Database, SQLite, Azure Cosmos DB, MySQL, PostgreSQL and MongoDB.

How to use:

In program.cs add the below code snipet.

//Nuget installation Install Jay.EFCore.UnitOfWork

//EFCore configurations

var conString = builder.Configuration["ConnectionStrings:ProductDbConnection"];
builder.Services.AddDbContextPool<ProductDbContext>(options => options.UseSqlServer(conString));
builder.Services.AddTransient<IJayDbContext, ProductDbContext>();

//Jay.EFCore.UnitOfWork configuaration

builder.Services.AddEFCoreUnitOfWork();

//Make sure your DbContext class implements IJayDbContext

internal class ProductDbContext : DbContext, IJayDbContext
{
    public ProductDbContext(DbContextOptions<ProductDbContext> options) : base(options)
    {
    }

    public DbSet<Product> Products { get; init; }
    public DbSet<ProductBrand> ProductBrands { get; init; }
    public DbSet<ProductType> ProductTypes { get; init; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        modelBuilder.ApplyConfigurationsFromAssembly(typeof(ProductConfiguration).Assembly);
    }

}

Do the following to use Jay.EFCore.UnitOfWork

 public class CreateProductHandler : IRequestHandler<CreateProductCommand, Product>
 {
     private readonly IUnitOfWorkCore _unitOfWork;

     public CreateProductHandler(IUnitOfWorkCore unitOfWork)
     {
         _unitOfWork = unitOfWork;
     }

     public async Task<Product> Handle(CreateProductCommand request, CancellationToken cancellationToken)
     {
         //Create new Product
         retur await _unitOfWork.Repository<Product>().AddAsync(request.Product, cancellationToken);
     }
 }

//=======================================================

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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
1.0.5 223 8/18/2024
1.0.4 184 8/18/2024
1.0.3 178 8/17/2024
1.0.2 188 8/16/2024
1.0.1 203 8/16/2024 1.0.1 is deprecated because it has critical bugs.
1.0.0 203 8/16/2024 1.0.0 is deprecated because it has critical bugs.

//=====================================================
Jay.EFCore.UnitOfWork

A dynamic repository and UnitOfWork implementation for Entity Framework Core,
incorporating IDisposable to enhance the scalability and efficiency of your CRUD operations.
Jay.EFCore.UnitOfWork works with EF Core for SQL Server,
Azure SQL Database, SQLite, Azure Cosmos DB, MySQL, PostgreSQL and MongoDB.

How to use:

In program.cs add the below code snipet.

//Nuget installation
Install Jay.EFCore.UnitOfWork

//EFCore configurations
var conString = builder.Configuration["ConnectionStrings:ProductDbConnection"];
builder.Services.AddDbContextPool<ProductDbContext>(options => options.UseSqlServer(conString));
builder.Services.AddTransient<IJayDbContext, ProductDbContext>();

//Jay.EFCore.UnitOfWork configuaration
builder.Services.AddEFCoreUnitOfWork();

//Make sure your DbContext class implements IJayDbContext
internal class ProductDbContext : DbContext, IJayDbContext
{
   public ProductDbContext(DbContextOptions<ProductDbContext> options) : base(options)
   {
   }

   public DbSet<Product> Products { get; init; }
   public DbSet<ProductBrand> ProductBrands { get; init; }
   public DbSet<ProductType> ProductTypes { get; init; }

   protected override void OnModelCreating(ModelBuilder modelBuilder)
   {
       base.OnModelCreating(modelBuilder);

       modelBuilder.ApplyConfigurationsFromAssembly(typeof(ProductConfiguration).Assembly);
   }

}

Do the following to use Jay.EFCore.UnitOfWork

public class CreateProductHandler : IRequestHandler<CreateProductCommand, Product>
{
    private readonly IUnitOfWorkCore _unitOfWork;

    public CreateProductHandler(IUnitOfWorkCore unitOfWork)
    {
        _unitOfWork = unitOfWork;
    }

    public async Task<Product> Handle(CreateProductCommand request, CancellationToken cancellationToken)
    {
        //Create new Product
        retur await _unitOfWork.Repository<Product>().AddAsync(request.Product, cancellationToken);
    }
}
//=======================================================