Skip to content

Commit dac717d

Browse files
committed
Fix Rainbow Database.Dispose() so that it never throws and not overrides the active exception (if any)
1 parent d19d601 commit dac717d

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Dapper.Rainbow/Database.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,10 @@ public SqlMapper.GridReader QueryMultiple(string sql, dynamic param = null, IDbT
466466
/// </summary>
467467
public void Dispose()
468468
{
469-
if (_connection.State != ConnectionState.Closed)
470-
{
471-
_transaction?.Rollback();
472-
473-
_connection.Close();
474-
_connection = null;
475-
}
469+
var connection = _connection;
470+
_connection = null;
471+
_transaction = null;
472+
connection?.Close();
476473
}
477474
}
478475
}

0 commit comments

Comments
 (0)