YDotNet.UnitOfWork 1.0.1

dotnet add package YDotNet.UnitOfWork --version 1.0.1
                    
NuGet\Install-Package YDotNet.UnitOfWork -Version 1.0.1
                    
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="YDotNet.UnitOfWork" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YDotNet.UnitOfWork" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="YDotNet.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 YDotNet.UnitOfWork --version 1.0.1
                    
#r "nuget: YDotNet.UnitOfWork, 1.0.1"
                    
#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.
#addin nuget:?package=YDotNet.UnitOfWork&version=1.0.1
                    
Install YDotNet.UnitOfWork as a Cake Addin
#tool nuget:?package=YDotNet.UnitOfWork&version=1.0.1
                    
Install YDotNet.UnitOfWork as a Cake Tool

🔄 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 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. 
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.1 181 a month ago