@@ -197,10 +197,7 @@ public void Disconnect()
197197
198198 public FbTransaction BeginTransaction ( IsolationLevel level , string transactionName )
199199 {
200- if ( HasActiveTransaction )
201- {
202- throw new InvalidOperationException ( "A transaction is currently active. Parallel transactions are not supported." ) ;
203- }
200+ EnsureActiveTransaction ( ) ;
204201
205202 try
206203 {
@@ -222,16 +219,11 @@ public FbTransaction BeginTransaction(IsolationLevel level, string transactionNa
222219
223220 public FbTransaction BeginTransaction ( FbTransactionOptions options , string transactionName )
224221 {
225- if ( HasActiveTransaction )
226- {
227- throw new InvalidOperationException ( "A transaction is currently active. Parallel transactions are not supported." ) ;
228- }
222+ EnsureActiveTransaction ( ) ;
229223
230224 try
231225 {
232- _activeTransaction = new FbTransaction (
233- _owningConnection , IsolationLevel . Unspecified ) ;
234-
226+ _activeTransaction = new FbTransaction ( _owningConnection , IsolationLevel . Unspecified ) ;
235227 _activeTransaction . BeginTransaction ( options ) ;
236228
237229 if ( transactionName != null )
@@ -260,8 +252,7 @@ public void TransactionCompleted()
260252 {
261253 for ( int i = 0 ; i < _preparedCommands . Count ; i ++ )
262254 {
263- FbCommand command ;
264- if ( ! _preparedCommands [ i ] . TryGetTarget ( out command ) )
255+ if ( ! _preparedCommands [ i ] . TryGetTarget ( out FbCommand command ) )
265256 continue ;
266257
267258 if ( command . Transaction != null )
@@ -352,8 +343,7 @@ public void AddPreparedCommand(FbCommand command)
352343 int position = _preparedCommands . Count ;
353344 for ( int i = 0 ; i < _preparedCommands . Count ; i ++ )
354345 {
355- FbCommand current ;
356- if ( ! _preparedCommands [ i ] . TryGetTarget ( out current ) )
346+ if ( ! _preparedCommands [ i ] . TryGetTarget ( out FbCommand current ) )
357347 {
358348 position = i ;
359349 break ;
@@ -386,8 +376,7 @@ public void ReleasePreparedCommands()
386376 {
387377 for ( int i = 0 ; i < _preparedCommands . Count ; i ++ )
388378 {
389- FbCommand current ;
390- if ( ! _preparedCommands [ i ] . TryGetTarget ( out current ) )
379+ if ( ! _preparedCommands [ i ] . TryGetTarget ( out FbCommand current ) )
391380 continue ;
392381
393382 try
@@ -539,6 +528,12 @@ private int GetProcessId()
539528#endif
540529 return Process . GetCurrentProcess ( ) . Id ;
541530 }
531+
532+ private void EnsureActiveTransaction ( )
533+ {
534+ if ( HasActiveTransaction )
535+ throw new InvalidOperationException ( "A transaction is currently active. Parallel transactions are not supported." ) ;
536+ }
542537 #endregion
543538
544539 #region Cancelation
0 commit comments