ABP Framework's Unit Of Work (UOW) implementation provides an abstraction and control on a **database transaction** scope in an application.
ABP Framework's Unit Of Work (UOW) implementation provides an abstraction and control on a **database connection and transaction** scope in an application.
Once a new UOW started, it creates an **ambient scope** that is participated by **all the database operations** performed in the current scope and considered as a **single transaction**,**committed** (on success) or **rolled back** (on exception) all together.
Once a new UOW started, it creates an **ambient scope** that is participated by **all the database operations** performed in the current scope and considered as a **single transaction boundary**. The operations are**committed** (on success) or **rolled back** (on exception) all together.
ABP's UOW system is;
ABP's UOW system is;
@ -19,11 +19,11 @@ The following method types are considered as a unit of work:
* **Application service** methods.
* **Application service** methods.
* **Repository methods**.
* **Repository methods**.
A UOW automatically begins for these methods except if there is already a **surrounding (ambient)** UOW in action. Examples;
A UOW automatically begins for these methods **except** if there is already a **surrounding (ambient)** UOW in action. Examples;
* If you call a [repository](Repositories.md) method and there is no UOW started yet, it automatically **begins a new transactional UOW** that involves all the operations done in the repository method and **commits the transaction** if the repository method **doesn't throw any exception.** The repository method doesn't know about UOW or transaction at all. It just works on a regular database objects (DbContext for [EF Core](Entity-Framework-Core.md), for example) and the UOW is handled by the ABP Framework.
* If you call a [repository](Repositories.md) method and there is no UOW started yet, it automatically **begins a new transactional UOW** that involves all the operations done in the repository method and **commits the transaction** if the repository method **doesn't throw any exception.** The repository method doesn't know about UOW or transaction at all. It just works on a regular database objects (`DbContext` for [EF Core](Entity-Framework-Core.md), for example) and the UOW is handled by the ABP Framework.
* If you call an [application service](Application-Services.md) method, the same UOW system works just as explained above. If the application service method uses some repositories, the repositories **don't begin a new UOW**, but **participates to the current unit of work** started by the ABP Framework for the application service method.
* If you call an [application service](Application-Services.md) method, the same UOW system works just as explained above. If the application service method uses some repositories, the repositories **don't begin a new UOW**, but **participates to the current unit of work** started by the ABP Framework for the application service method.
* The same is true for an ASP.NET Core controller action. If the operation has started with a controller action, then the **UOW scope is the controller action method body**.
* The same is true for an ASP.NET Core controller action. If the operation has started with a controller action, then the **UOW scope is the controller action's method body**.
All of these are automatically handled by the ABP Framework. The rest of this document explains the UOW system in details and options provided to a fine control the UOW system.
All of these are automatically handled by the ABP Framework. The rest of this document explains the UOW system in details and options provided to fine control the UOW system.