YDotNet.UnitOfWork
2.0.0
dotnet add package YDotNet.UnitOfWork --version 2.0.0
NuGet\Install-Package YDotNet.UnitOfWork -Version 2.0.0
<PackageReference Include="YDotNet.UnitOfWork" Version="2.0.0" />
<PackageVersion Include="YDotNet.UnitOfWork" Version="2.0.0" />
<PackageReference Include="YDotNet.UnitOfWork" />
paket add YDotNet.UnitOfWork --version 2.0.0
#r "nuget: YDotNet.UnitOfWork, 2.0.0"
#:package YDotNet.UnitOfWork@2.0.0
#addin nuget:?package=YDotNet.UnitOfWork&version=2.0.0
#tool nuget:?package=YDotNet.UnitOfWork&version=2.0.0
🔄 Unit of Work Pattern for Entity Framework Core
This library provides a simple and efficient implementation of the Unit of Work pattern for Entity Framework Core applications. Inspired by best practices, this ensures that all database operations within a business transaction are handled consistently and atomically.
🔗 NuGet Package: YDotNet.UnitOfWork
✨ Features
✅ Clean abstraction over Entity Framework Core's DbContext
✅ Async save operations for better performance
✅ Seamless integration with dependency injection
✅ Supports any EF Core DbContext
📦 Installation
Add the package to your project:
dotnet add package YDotNet.UnitOfWork
🚀 Usage
1️⃣ Setup
Register the Unit of Work with your DbContext
in Program.cs
:
builder.Services.AddUnitOfWork<AppDbContext>();
2️⃣ Dependency Injection
Inject IUnitOfWork
into your services or controllers:
public class MyService
{
private readonly IUnitOfWork _unitOfWork;
public MyService(IUnitOfWork unitOfWork)
{
_unitOfWork = unitOfWork;
}
}
3️⃣ Using the Unit of Work
public class MyService
{
private readonly IUnitOfWork _unitOfWork;
private readonly DbContext _context;
public MyService(IUnitOfWork unitOfWork, DbContext context)
{
_unitOfWork = unitOfWork;
_context = context;
}
public async Task SaveDataAsync()
{
// Perform database operations
_context.Users.Add(new User { Name = "John" });
// Save all changes atomically
await _unitOfWork.SaveChangesAsync();
}
}
🔧 Requirements
- 🟢 .NET 6.0 or higher
- 🟢 Entity Framework Core 6.0 or higher
📜 License
📝 MIT License – Free to use and modify!
🤝 Contributing
Contributions are welcome! 🚀 Feel free to submit issues, enhancements, or pull requests.
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.13)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.