Addition to transaction fix
This commit is contained in:
parent
db5e820841
commit
43f647d9b7
@ -43,8 +43,10 @@ namespace RMDataManagerLibrary.Internal.DataAccess
|
||||
|
||||
private IDbConnection _connection;
|
||||
private IDbTransaction _transaction;
|
||||
private bool isClosed = false;
|
||||
public void StartTransaction(string connectionStringName)
|
||||
{
|
||||
isClosed = false;
|
||||
string connectionString = GetConnectionString(connectionStringName);
|
||||
|
||||
_connection = new SqlConnection(connectionString);
|
||||
@ -74,17 +76,32 @@ namespace RMDataManagerLibrary.Internal.DataAccess
|
||||
{
|
||||
_transaction?.Commit();
|
||||
_connection?.Close();
|
||||
isClosed = true;
|
||||
}
|
||||
|
||||
public void RollBackTransaction()
|
||||
{
|
||||
_transaction?.Rollback();
|
||||
_connection?.Close();
|
||||
isClosed = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
CommitTransaction();
|
||||
if (!isClosed)
|
||||
{
|
||||
try
|
||||
{
|
||||
CommitTransaction();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO - log this issue
|
||||
}
|
||||
}
|
||||
|
||||
_transaction = null;
|
||||
_connection = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user