@@ -17,8 +17,6 @@ namespace Xtensive.Sql.Drivers.PostgreSql
1717{
1818 internal class Connection : SqlConnection
1919 {
20- private static readonly Func < NpgsqlTransaction , bool > TransactionIsCompleteAccessor ;
21-
2220 private NpgsqlConnection underlyingConnection ;
2321 private NpgsqlTransaction activeTransaction ;
2422
@@ -185,7 +183,7 @@ private async Task ExecuteNonQueryAsync(string commandText, CancellationToken to
185183
186184 private bool IsTransactionCompleted ( )
187185 {
188- return activeTransaction != null && TransactionIsCompleteAccessor ( activeTransaction ) ;
186+ return activeTransaction != null && activeTransaction . Connection == null ;
189187 }
190188
191189 // Constructors
@@ -196,19 +194,5 @@ public Connection(SqlDriver driver)
196194 {
197195 underlyingConnection = new NpgsqlConnection ( ) ;
198196 }
199-
200- static Connection ( )
201- {
202- // We have to use reflection to keep current behavior.
203- // The prop was public but they changed it to internal though it is read-only
204- // and didn't harm internal state.
205- // But it is important for us to know whether active transaction was completed
206- // to not try to make some actions.
207- var isCompletedProp = typeof ( NpgsqlTransaction )
208- . GetProperty ( "IsCompleted" , BindingFlags . Instance | BindingFlags . NonPublic )
209- ?? throw new NullReferenceException ( ) ;
210-
211- TransactionIsCompleteAccessor = ( Func < NpgsqlTransaction , bool > ) Delegate . CreateDelegate ( typeof ( Func < NpgsqlTransaction , bool > ) , isCompletedProp . GetMethod ) ;
212- }
213197 }
214198}
0 commit comments