@@ -13,26 +13,26 @@ public override void Commit() =>
13
13
CommitAsync ( IOBehavior . Synchronous , CancellationToken . None ) . GetAwaiter ( ) . GetResult ( ) ;
14
14
15
15
public Task CommitAsync ( CancellationToken cancellationToken = default ) =>
16
- CommitAsync ( m_connection ? . AsyncIOBehavior ?? IOBehavior . Asynchronous , cancellationToken ) ;
16
+ CommitAsync ( Connection ? . AsyncIOBehavior ?? IOBehavior . Asynchronous , cancellationToken ) ;
17
17
18
18
internal async Task CommitAsync ( IOBehavior ioBehavior , CancellationToken cancellationToken )
19
19
{
20
20
VerifyNotDisposed ( ) ;
21
- if ( m_connection == null )
21
+ if ( Connection == null )
22
22
throw new InvalidOperationException ( "Already committed or rolled back." ) ;
23
23
24
- if ( m_connection . CurrentTransaction == this )
24
+ if ( Connection . CurrentTransaction == this )
25
25
{
26
- using ( var cmd = new MySqlCommand ( "commit" , m_connection , this ) )
26
+ using ( var cmd = new MySqlCommand ( "commit" , Connection , this ) )
27
27
await cmd . ExecuteNonQueryAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
28
- m_connection . CurrentTransaction = null ;
29
- m_connection = null ;
28
+ Connection . CurrentTransaction = null ;
29
+ Connection = null ;
30
30
}
31
- else if ( m_connection . CurrentTransaction != null )
31
+ else if ( Connection . CurrentTransaction != null )
32
32
{
33
33
throw new InvalidOperationException ( "This is not the active transaction." ) ;
34
34
}
35
- else if ( m_connection . CurrentTransaction == null )
35
+ else if ( Connection . CurrentTransaction == null )
36
36
{
37
37
throw new InvalidOperationException ( "There is no active transaction." ) ;
38
38
}
@@ -42,33 +42,33 @@ public override void Rollback() =>
42
42
RollbackAsync ( IOBehavior . Synchronous , CancellationToken . None ) . GetAwaiter ( ) . GetResult ( ) ;
43
43
44
44
public Task RollbackAsync ( CancellationToken cancellationToken = default ) =>
45
- RollbackAsync ( m_connection ? . AsyncIOBehavior ?? IOBehavior . Asynchronous , cancellationToken ) ;
45
+ RollbackAsync ( Connection ? . AsyncIOBehavior ?? IOBehavior . Asynchronous , cancellationToken ) ;
46
46
47
47
internal async Task RollbackAsync ( IOBehavior ioBehavior , CancellationToken cancellationToken )
48
48
{
49
49
VerifyNotDisposed ( ) ;
50
- if ( m_connection == null )
50
+ if ( Connection == null )
51
51
throw new InvalidOperationException ( "Already committed or rolled back." ) ;
52
52
53
- if ( m_connection . CurrentTransaction == this )
53
+ if ( Connection . CurrentTransaction == this )
54
54
{
55
- using ( var cmd = new MySqlCommand ( "rollback" , m_connection , this ) )
55
+ using ( var cmd = new MySqlCommand ( "rollback" , Connection , this ) )
56
56
await cmd . ExecuteNonQueryAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
57
- m_connection . CurrentTransaction = null ;
58
- m_connection = null ;
57
+ Connection . CurrentTransaction = null ;
58
+ Connection = null ;
59
59
}
60
- else if ( m_connection . CurrentTransaction != null )
60
+ else if ( Connection . CurrentTransaction != null )
61
61
{
62
62
throw new InvalidOperationException ( "This is not the active transaction." ) ;
63
63
}
64
- else if ( m_connection . CurrentTransaction == null )
64
+ else if ( Connection . CurrentTransaction == null )
65
65
{
66
66
throw new InvalidOperationException ( "There is no active transaction." ) ;
67
67
}
68
68
}
69
69
70
- public new MySqlConnection Connection => m_connection ;
71
- protected override DbConnection DbConnection => m_connection ;
70
+ public new MySqlConnection Connection { get ; private set ; }
71
+ protected override DbConnection DbConnection => Connection ;
72
72
public override IsolationLevel IsolationLevel { get ; }
73
73
74
74
protected override void Dispose ( bool disposing )
@@ -78,16 +78,16 @@ protected override void Dispose(bool disposing)
78
78
if ( disposing )
79
79
{
80
80
m_isDisposed = true ;
81
- if ( m_connection ? . CurrentTransaction == this )
81
+ if ( Connection ? . CurrentTransaction == this )
82
82
{
83
- if ( m_connection . Session . IsConnected )
83
+ if ( Connection . Session . IsConnected )
84
84
{
85
- using ( var cmd = new MySqlCommand ( "rollback" , m_connection , this ) )
85
+ using ( var cmd = new MySqlCommand ( "rollback" , Connection , this ) )
86
86
cmd . ExecuteNonQuery ( ) ;
87
87
}
88
- m_connection . CurrentTransaction = null ;
88
+ Connection . CurrentTransaction = null ;
89
89
}
90
- m_connection = null ;
90
+ Connection = null ;
91
91
}
92
92
}
93
93
finally
@@ -98,7 +98,7 @@ protected override void Dispose(bool disposing)
98
98
99
99
internal MySqlTransaction ( MySqlConnection connection , IsolationLevel isolationLevel )
100
100
{
101
- m_connection = connection ;
101
+ Connection = connection ;
102
102
IsolationLevel = isolationLevel ;
103
103
}
104
104
@@ -108,7 +108,6 @@ private void VerifyNotDisposed()
108
108
throw new ObjectDisposedException ( nameof ( MySqlTransaction ) ) ;
109
109
}
110
110
111
- MySqlConnection m_connection ;
112
111
bool m_isDisposed ;
113
112
}
114
113
}
0 commit comments