YDotNet.UnitOfWork
1.0.1
dotnet add package YDotNet.UnitOfWork --version 1.0.1
NuGet\Install-Package YDotNet.UnitOfWork -Version 1.0.1
<PackageReference Include="YDotNet.UnitOfWork" Version="1.0.1" />
<PackageVersion Include="YDotNet.UnitOfWork" Version="1.0.1" />
<PackageReference Include="YDotNet.UnitOfWork" />
paket add YDotNet.UnitOfWork --version 1.0.1
#r "nuget: YDotNet.UnitOfWork, 1.0.1"
#addin nuget:?package=YDotNet.UnitOfWork&version=1.0.1
#tool nuget:?package=YDotNet.UnitOfWork&version=1.0.1
🔄 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.
✨ 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 Yander.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. |
-
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.
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 181 | a month ago |