unit-of-work

Provides atomic transaction control for .NET Clean Architecture write operations.

Updated Feb 20, 2026
One-click install
npx skills add https://github.com/yeeehaooo/WorkSpace --skill unit-of-work
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unit-of-work
Source: https://github.com/yeeehaooo/WorkSpace/tree/main/skills/dotnet/patterns/unit-of-work
Command: npx skills add https://github.com/yeeehaooo/WorkSpace --skill unit-of-work

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provide transactional boundary control for write operations in .NET Clean Architecture applications.

Core Features & Use Cases

  • Use-case: Implementing command handlers that require database transactions
  • Use-case: Managing transaction boundaries across multiple repository operations
  • Use-case: Coordinating atomic operations in Clean Architecture applications
  • Use-case: Handling nested transactions in scoped dependency injection scenarios
  • Use-case: Preventing repository-level transaction management anti-patterns

Quick Start

Configure a UnitOfWork at the start of a command handler to begin a transaction, perform repository operations, and commit or rollback as needed.

Frequently Asked Questions about unit-of-work

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage transaction boundaries across multiple repositories in .NET Clean Architecture?

To manage transaction boundaries across multiple repositories in .NET Clean Architecture, define IUnitOfWork in the Application layer and implement it in Infrastructure to coordinate atomic multi-repository updates, exposing BeginAsync, CommitAsync, and RollbackAsync methods.

What is the Unit of Work pattern for coordinating atomic operations in CQRS applications?

The Unit of Work pattern for coordinating atomic operations in CQRS applications provides transactional boundary control for write operations, ensuring commands that require multiple repository updates execute atomically or roll back entirely.

Can I handle nested transactions in scoped dependency injection scenarios using .NET?

Yes, you can handle nested transactions in scoped dependency injection scenarios using .NET by implementing a UnitOfWork pattern that supports nested transactions, utilizing an internal IDbSession and providing automatic rollback on Dispose.

Why should I prevent repositories from managing their own database transactions in Clean Architecture?

Preventing repositories from managing their own database transactions in Clean Architecture avoids anti-patterns by centralizing transactional boundary control at the command handler level, ensuring atomic operations and consistent multi-repository updates.

How do I implement transaction management command handlers in .NET with Dapper?

To implement transaction management command handlers in .NET with Dapper, configure a DapperUnitOfWork at the start of the handler to begin a transaction, perform repository operations, and commit or rollback as needed using the exposed async methods.

Does the Unit of Work pattern support automatic rollback on unhandled exceptions in .NET?

Yes, the Unit of Work pattern supports automatic rollback on unhandled exceptions in .NET by triggering rollback during the Dispose phase of the scoped dependency injection lifecycle, ensuring atomic multi-repository updates remain consistent.