File tree 2 files changed +16
-3
lines changed
src/MiniProfiler.Shared/Data
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,12 @@ public override UpdateRowSource UpdatedRowSource
196
196
set => _command . UpdatedRowSource = value ;
197
197
}
198
198
199
+ /// <summary>
200
+ /// Creates a wrapper data reader for <see cref="ExecuteDbDataReader"/> and <see cref="ExecuteDbDataReaderAsync"/> />
201
+ /// </summary>
202
+ protected virtual DbDataReader CreateDbDataReader ( DbDataReader original , IDbProfiler profiler )
203
+ => new ProfiledDbDataReader ( original , profiler ) ;
204
+
199
205
/// <summary>
200
206
/// Executes a database data reader.
201
207
/// </summary>
@@ -213,7 +219,7 @@ protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
213
219
try
214
220
{
215
221
result = _command . ExecuteReader ( behavior ) ;
216
- result = new ProfiledDbDataReader ( result , _profiler ) ;
222
+ result = CreateDbDataReader ( result , _profiler ) ;
217
223
}
218
224
catch ( Exception e )
219
225
{
@@ -246,7 +252,7 @@ protected override async Task<DbDataReader> ExecuteDbDataReaderAsync(CommandBeha
246
252
try
247
253
{
248
254
result = await _command . ExecuteReaderAsync ( behavior , cancellationToken ) . ConfigureAwait ( false ) ;
249
- result = new ProfiledDbDataReader ( result , _profiler ) ;
255
+ result = CreateDbDataReader ( result , _profiler ) ;
250
256
}
251
257
catch ( Exception e )
252
258
{
Original file line number Diff line number Diff line change @@ -137,12 +137,19 @@ protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLeve
137
137
{
138
138
return new ProfiledDbTransaction ( _connection . BeginTransaction ( isolationLevel ) , this ) ;
139
139
}
140
+
141
+ /// <summary>
142
+ /// Creates and returns a <see cref="DbCommand"/> object associated with the current connection.
143
+ /// </summary>
144
+ /// <returns>A <see cref="ProfiledDbCommand"/> wrapping the created <see cref="DbCommand"/>.</returns>
145
+ protected virtual DbCommand CreateDbCommand ( DbCommand original , IDbProfiler profiler )
146
+ => new ProfiledDbCommand ( original , this , profiler ) ;
140
147
141
148
/// <summary>
142
149
/// Creates and returns a <see cref="DbCommand"/> object associated with the current connection.
143
150
/// </summary>
144
151
/// <returns>A <see cref="ProfiledDbCommand"/> wrapping the created <see cref="DbCommand"/>.</returns>
145
- protected override DbCommand CreateDbCommand ( ) => new ProfiledDbCommand ( _connection . CreateCommand ( ) , this , _profiler ) ;
152
+ protected override DbCommand CreateDbCommand ( ) => CreateDbCommand ( _connection . CreateCommand ( ) , _profiler ) ;
146
153
147
154
/// <summary>
148
155
/// Dispose the underlying connection.
You can’t perform that action at this time.
0 commit comments