Member-only story
Unit of Work for ASP.NET Core
Part 3: Add transaction support for repositories
Hope y’all are familiar with ASP.NET Core articles following up to here introducing WebAPI and Generic Repository Pattern. If needed to follow up or for quick keep up please check up on:
Why Unit of Work?
Transaction support and connection management is essential in an application architecture. Simply given business scenario should entirely succeed or entirely fail and not remain in partial condition. As an example, let's consider A transferring 10 to B and that business scenario can be written in following pseudo code:
transfer(from A, to B, amount 10) {
A = A - 10
B = B + 10
}
This should be done in one go from database point of view. Simply lets assume the scenario where A = A — 10
is executed, but B = B + 10
failed to execute. From database point partial results should not be reflected, cause it will give false business scenario. As…