88using System . Data . Common ;
99using System . Security ;
1010using MySql . Data . MySqlClient ;
11- using Xtensive . Orm ;
1211
1312namespace Xtensive . Sql . Drivers . MySql
1413{
1514 internal class Connection : SqlConnection
1615 {
17- private readonly MySqlConnection underlyingConnection ;
16+ private MySqlConnection underlyingConnection ;
1817 private MySqlTransaction activeTransaction ;
1918
2019 /// <inheritdoc/>
@@ -40,22 +39,28 @@ public override DbParameter CreateParameter()
4039 [ SecuritySafeCritical ]
4140 public override void BeginTransaction ( )
4241 {
43- EnsureTrasactionIsNotActive ( ) ;
42+ EnsureIsNotDisposed ( ) ;
43+ EnsureTransactionIsNotActive ( ) ;
44+
4445 activeTransaction = underlyingConnection . BeginTransaction ( ) ;
4546 }
4647
4748 /// <inheritdoc/>
4849 [ SecuritySafeCritical ]
4950 public override void BeginTransaction ( IsolationLevel isolationLevel )
5051 {
51- EnsureTrasactionIsNotActive ( ) ;
52+ EnsureIsNotDisposed ( ) ;
53+ EnsureTransactionIsNotActive ( ) ;
54+
5255 activeTransaction = underlyingConnection . BeginTransaction ( SqlHelper . ReduceIsolationLevel ( isolationLevel ) ) ;
5356 }
5457
5558 /// <inheritdoc/>
5659 public override void MakeSavepoint ( string name )
5760 {
61+ EnsureIsNotDisposed ( ) ;
5862 EnsureTransactionIsActive ( ) ;
63+
5964 string commandText = string . Format ( "SAVEPOINT {0}" , name ) ;
6065 using ( DbCommand command = CreateCommand ( commandText ) )
6166 command . ExecuteNonQuery ( ) ;
@@ -64,7 +69,9 @@ public override void MakeSavepoint(string name)
6469 /// <inheritdoc/>
6570 public override void RollbackToSavepoint ( string name )
6671 {
72+ EnsureIsNotDisposed ( ) ;
6773 EnsureTransactionIsActive ( ) ;
74+
6875 string commandText = string . Format ( "ROLLBACK TO SAVEPOINT {0}; RELEASE SAVEPOINT {0};" , name ) ;
6976 using ( DbCommand command = CreateCommand ( commandText ) )
7077 command . ExecuteNonQuery ( ) ;
@@ -73,7 +80,9 @@ public override void RollbackToSavepoint(string name)
7380 /// <inheritdoc/>
7481 public override void ReleaseSavepoint ( string name )
7582 {
83+ EnsureIsNotDisposed ( ) ;
7684 EnsureTransactionIsActive ( ) ;
85+
7786 string commandText = string . Format ( "RELEASE SAVEPOINT {0}" , name ) ;
7887 using ( DbCommand command = CreateCommand ( commandText ) )
7988 command . ExecuteNonQuery ( ) ;
@@ -85,6 +94,12 @@ protected override void ClearActiveTransaction()
8594 activeTransaction = null ;
8695 }
8796
97+ /// <inheritdoc/>
98+ protected override void ClearUnderlyingConnection ( )
99+ {
100+ underlyingConnection = null ;
101+ }
102+
88103 // Constructors
89104
90105 [ SecuritySafeCritical ]
0 commit comments