@@ -197,10 +197,7 @@ public void Disconnect()
197
197
198
198
public FbTransaction BeginTransaction ( IsolationLevel level , string transactionName )
199
199
{
200
- if ( HasActiveTransaction )
201
- {
202
- throw new InvalidOperationException ( "A transaction is currently active. Parallel transactions are not supported." ) ;
203
- }
200
+ EnsureActiveTransaction ( ) ;
204
201
205
202
try
206
203
{
@@ -222,16 +219,11 @@ public FbTransaction BeginTransaction(IsolationLevel level, string transactionNa
222
219
223
220
public FbTransaction BeginTransaction ( FbTransactionOptions options , string transactionName )
224
221
{
225
- if ( HasActiveTransaction )
226
- {
227
- throw new InvalidOperationException ( "A transaction is currently active. Parallel transactions are not supported." ) ;
228
- }
222
+ EnsureActiveTransaction ( ) ;
229
223
230
224
try
231
225
{
232
- _activeTransaction = new FbTransaction (
233
- _owningConnection , IsolationLevel . Unspecified ) ;
234
-
226
+ _activeTransaction = new FbTransaction ( _owningConnection , IsolationLevel . Unspecified ) ;
235
227
_activeTransaction . BeginTransaction ( options ) ;
236
228
237
229
if ( transactionName != null )
@@ -260,8 +252,7 @@ public void TransactionCompleted()
260
252
{
261
253
for ( int i = 0 ; i < _preparedCommands . Count ; i ++ )
262
254
{
263
- FbCommand command ;
264
- if ( ! _preparedCommands [ i ] . TryGetTarget ( out command ) )
255
+ if ( ! _preparedCommands [ i ] . TryGetTarget ( out FbCommand command ) )
265
256
continue ;
266
257
267
258
if ( command . Transaction != null )
@@ -352,8 +343,7 @@ public void AddPreparedCommand(FbCommand command)
352
343
int position = _preparedCommands . Count ;
353
344
for ( int i = 0 ; i < _preparedCommands . Count ; i ++ )
354
345
{
355
- FbCommand current ;
356
- if ( ! _preparedCommands [ i ] . TryGetTarget ( out current ) )
346
+ if ( ! _preparedCommands [ i ] . TryGetTarget ( out FbCommand current ) )
357
347
{
358
348
position = i ;
359
349
break ;
@@ -386,8 +376,7 @@ public void ReleasePreparedCommands()
386
376
{
387
377
for ( int i = 0 ; i < _preparedCommands . Count ; i ++ )
388
378
{
389
- FbCommand current ;
390
- if ( ! _preparedCommands [ i ] . TryGetTarget ( out current ) )
379
+ if ( ! _preparedCommands [ i ] . TryGetTarget ( out FbCommand current ) )
391
380
continue ;
392
381
393
382
try
@@ -539,6 +528,12 @@ private int GetProcessId()
539
528
#endif
540
529
return Process . GetCurrentProcess ( ) . Id ;
541
530
}
531
+
532
+ private void EnsureActiveTransaction ( )
533
+ {
534
+ if ( HasActiveTransaction )
535
+ throw new InvalidOperationException ( "A transaction is currently active. Parallel transactions are not supported." ) ;
536
+ }
542
537
#endregion
543
538
544
539
#region Cancelation
0 commit comments