File tree 1 file changed +18
-8
lines changed
1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -359,8 +359,11 @@ public void CloseReader(DbDataReader reader)
359
359
var actualReader = rsw == null ? reader : rsw . Target ;
360
360
_readersToClose . Remove ( actualReader ) ;
361
361
362
+ var duration = GetReaderStopwatch ( actualReader ) ;
363
+
362
364
try
363
365
{
366
+ //TODO: Shouldn't we close reader instead?
364
367
reader . Dispose ( ) ;
365
368
}
366
369
catch ( Exception e )
@@ -370,17 +373,24 @@ public void CloseReader(DbDataReader reader)
370
373
}
371
374
372
375
LogCloseReader ( ) ;
376
+ LogDuration ( duration ) ;
377
+ }
373
378
374
- if ( ! Log . IsDebugEnabled )
375
- return ;
376
-
377
- var nhReader = actualReader as NHybridDataReader ;
378
- actualReader = nhReader == null ? actualReader : nhReader . Target ;
379
+ private Stopwatch GetReaderStopwatch ( DbDataReader reader )
380
+ {
381
+ var nhReader = reader as NHybridDataReader ;
382
+ var actualReader = nhReader == null ? reader : nhReader . Target ;
379
383
380
384
Stopwatch duration ;
381
- if ( _readersDuration . TryGetValue ( actualReader , out duration ) == false )
382
- return ;
383
- _readersDuration . Remove ( actualReader ) ;
385
+ if ( _readersDuration . TryGetValue ( actualReader , out duration ) )
386
+ _readersDuration . Remove ( actualReader ) ;
387
+ return duration ;
388
+ }
389
+
390
+ private static void LogDuration ( Stopwatch duration )
391
+ {
392
+ if ( ! Log . IsDebugEnabled || duration == null ) return ;
393
+
384
394
Log . DebugFormat ( "DataReader was closed after {0} ms" , duration . ElapsedMilliseconds ) ;
385
395
}
386
396
You can’t perform that action at this time.
0 commit comments