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
<PackageReference Include="Jay.EFCore.UnitOfWork" Version="1.0.5" />
<PackageVersion Include="Jay.EFCore.UnitOfWork" Version="1.0.5" />
<PackageReference Include="Jay.EFCore.UnitOfWork" />
paket add Jay.EFCore.UnitOfWork --version 1.0.5
#r "nuget: Jay.EFCore.UnitOfWork, 1.0.5"
#:package Jay.EFCore.UnitOfWork@1.0.5
#addin nuget:?package=Jay.EFCore.UnitOfWork&version=1.0.5
#tool nuget:?package=Jay.EFCore.UnitOfWork&version=1.0.5
//===================================================== 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 | 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. 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. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.8)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
//=====================================================
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);
}
}
//=======================================================