using System.Data;
using Galaeth.Core.Infrastructure;
using Injectio.Attributes;
namespace Galaeth.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);
}
}