# Transaction Pattern > Part of `Mango.Nop.Data`. See `Mango.Nop.Data/README.md` for project overview. > For repository base classes see `docs/REPOSITORIES.md`. ## MgDbContextBase Abstract database context base. NOT an EF Core DbContext — wraps `INopDataProvider` and `IRepository` nopCommerce repos. **Constructor:** ```csharp MgDbContextBase(IRepository, IRepository, IRepository, INopDataProvider, IMgLockService, ILogger) ``` ### Standard Repositories | Property | Type | |---|---| | `Orders` | `IRepository` | | `OrderItems` | `IRepository` | | `Products` | `IRepository` | | `DataProvider` | `INopDataProvider` (LinqToDB raw queries) | | `Logger` | Mango `ILogger` | | `LockService` | `IMgLockService` (global `SemaphoreSlim`) | ### 4 Transaction Methods | Method | Lock | Async | |---|---|---| | `Transaction(callback)` | No | No | | `TransactionSafe(callback)` | `SemaphoreSlim` | No | | `TransactionAsync(callback)` | No | Yes (thread pool) | | `TransactionSafeAsync(callback)` | `SemaphoreSlim` | Yes (thread pool) | **Callback contract:** `Func)>` — return `true` to commit (`Complete()`), `false` to rollback. **Isolation level:** `ReadCommitted` **Error handling:** Catches exceptions, logs, returns `false` (unless `throwException = true`). **TransactionSafe variants:** Use `LockService.SemaphoreSlim` for global serialization. Use for order creation, stock adjustment — any operation where concurrent modifications would corrupt data. **Async variants:** Run on thread pool via `TaskHelper.ToThreadPoolTask()`. ## MgDalBase\ Data Access Layer orchestrator. Thin wrapper exposing: | Property | Type | Purpose | |---|---|---| | `Name` | `string` | DAL instance name | | `Context` | `TDbContext` | The DB context (typed) | | `MutextLock` | `Mutex` | Cross-process locking |