// // Copyright (c) alveus.dev. All rights reserved. Licensed under the MIT License. // using System.Data; using Astral.Core.Infrastructure; using Injectio.Attributes; namespace Astral.DAL.Infrastructure; /// [RegisterScoped] public class TransactionProvider : ITransactionProvider { private readonly IDbConnectionProvider _dbConnectionProvider; /// /// Initializes a new instance of the class. /// /// Instance of . public TransactionProvider(IDbConnectionProvider dbConnectionProvider) { _dbConnectionProvider = dbConnectionProvider; } /// public IDbTransaction BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.Unspecified) { var connection = _dbConnectionProvider.OpenConnection(); return connection.BeginTransaction(isolationLevel); } /// public async Task BeginTransactionAsync(IsolationLevel isolationLevel = IsolationLevel.Unspecified) { var connection = await _dbConnectionProvider.OpenConnectionAsync(); return connection.BeginTransaction(isolationLevel); } }