File tree 1 file changed +17
-8
lines changed 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -359,6 +359,8 @@ 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
{
364
366
reader . Dispose ( ) ;
@@ -370,17 +372,24 @@ public void CloseReader(DbDataReader reader)
370
372
}
371
373
372
374
LogCloseReader ( ) ;
375
+ LogDuration ( duration ) ;
376
+ }
373
377
374
- if ( ! Log . IsDebugEnabled )
375
- return ;
376
-
377
- var nhReader = actualReader as NHybridDataReader ;
378
- actualReader = nhReader == null ? actualReader : nhReader . Target ;
378
+ private Stopwatch GetReaderStopwatch ( DbDataReader reader )
379
+ {
380
+ var nhReader = reader as NHybridDataReader ;
381
+ var actualReader = nhReader == null ? reader : nhReader . Target ;
379
382
380
383
Stopwatch duration ;
381
- if ( _readersDuration . TryGetValue ( actualReader , out duration ) == false )
382
- return ;
383
- _readersDuration . Remove ( actualReader ) ;
384
+ if ( _readersDuration . TryGetValue ( actualReader , out duration ) )
385
+ _readersDuration . Remove ( actualReader ) ;
386
+ return duration ;
387
+ }
388
+
389
+ private static void LogDuration ( Stopwatch duration )
390
+ {
391
+ if ( ! Log . IsDebugEnabled || duration == null ) return ;
392
+
384
393
Log . DebugFormat ( "DataReader was closed after {0} ms" , duration . ElapsedMilliseconds ) ;
385
394
}
386
395
You can’t perform that action at this time.
0 commit comments