From 0fb70801d20c8f4e7166b8e923075f50553b0bc7 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 14 Sep 2018 09:30:52 +0300 Subject: [PATCH 1/3] Added extension points for creating ProfiledDbCommand and ProfiledDbDataReader --- src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs | 7 +++++-- src/MiniProfiler.Shared/Data/ProfiledDbConnection.cs | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs b/src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs index 3cdb7feec..7629cd147 100644 --- a/src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs +++ b/src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs @@ -196,6 +196,9 @@ public override UpdateRowSource UpdatedRowSource set => _command.UpdatedRowSource = value; } + protected virtual DbDataReader CreateDataReader(DbDataReader original, IDbProfiler profiler) + => new ProfiledDbDataReader(original, profiler); + /// /// Executes a database data reader. /// @@ -213,7 +216,7 @@ protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) try { result = _command.ExecuteReader(behavior); - result = new ProfiledDbDataReader(result, _profiler); + result = CreateDataReader(result, _profiler); } catch (Exception e) { @@ -246,7 +249,7 @@ protected override async Task ExecuteDbDataReaderAsync(CommandBeha try { result = await _command.ExecuteReaderAsync(behavior, cancellationToken).ConfigureAwait(false); - result = new ProfiledDbDataReader(result, _profiler); + result = CreateDataReader(result, _profiler); } catch (Exception e) { diff --git a/src/MiniProfiler.Shared/Data/ProfiledDbConnection.cs b/src/MiniProfiler.Shared/Data/ProfiledDbConnection.cs index 541607f6f..dd055fd23 100644 --- a/src/MiniProfiler.Shared/Data/ProfiledDbConnection.cs +++ b/src/MiniProfiler.Shared/Data/ProfiledDbConnection.cs @@ -137,12 +137,15 @@ protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLeve { return new ProfiledDbTransaction(_connection.BeginTransaction(isolationLevel), this); } + + protected virtual DbCommand CreateDbCommand(DbCommand original, IDbProfiler profiler) + => new ProfiledDbCommand(original, this, profiler); /// /// Creates and returns a object associated with the current connection. /// /// A wrapping the created . - protected override DbCommand CreateDbCommand() => new ProfiledDbCommand(_connection.CreateCommand(), this, _profiler); + protected override DbCommand CreateDbCommand() => CreateDbCommand(_connection.CreateCommand(), _profiler); /// /// Dispose the underlying connection. From 03883a35b1ee63fa6021d8664af3c55ebaedc339 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 14 Sep 2018 09:33:28 +0300 Subject: [PATCH 2/3] xmldoc --- src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs | 3 +++ src/MiniProfiler.Shared/Data/ProfiledDbConnection.cs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs b/src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs index 7629cd147..dba14e499 100644 --- a/src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs +++ b/src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs @@ -196,6 +196,9 @@ public override UpdateRowSource UpdatedRowSource set => _command.UpdatedRowSource = value; } + /// + /// Creates a wrapper data reader for and /> + /// protected virtual DbDataReader CreateDataReader(DbDataReader original, IDbProfiler profiler) => new ProfiledDbDataReader(original, profiler); diff --git a/src/MiniProfiler.Shared/Data/ProfiledDbConnection.cs b/src/MiniProfiler.Shared/Data/ProfiledDbConnection.cs index dd055fd23..0edc59f2e 100644 --- a/src/MiniProfiler.Shared/Data/ProfiledDbConnection.cs +++ b/src/MiniProfiler.Shared/Data/ProfiledDbConnection.cs @@ -138,6 +138,10 @@ protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLeve return new ProfiledDbTransaction(_connection.BeginTransaction(isolationLevel), this); } + /// + /// Creates and returns a object associated with the current connection. + /// + /// A wrapping the created . protected virtual DbCommand CreateDbCommand(DbCommand original, IDbProfiler profiler) => new ProfiledDbCommand(original, this, profiler); From 4c47c2f5a34902ce0f995624676cef711fd0f308 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 14 Sep 2018 19:54:38 +0300 Subject: [PATCH 3/3] CreateDataReader->CreateDbDataReader --- src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs b/src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs index dba14e499..c5abb1592 100644 --- a/src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs +++ b/src/MiniProfiler.Shared/Data/ProfiledDbCommand.cs @@ -199,7 +199,7 @@ public override UpdateRowSource UpdatedRowSource /// /// Creates a wrapper data reader for and /> /// - protected virtual DbDataReader CreateDataReader(DbDataReader original, IDbProfiler profiler) + protected virtual DbDataReader CreateDbDataReader(DbDataReader original, IDbProfiler profiler) => new ProfiledDbDataReader(original, profiler); /// @@ -219,7 +219,7 @@ protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) try { result = _command.ExecuteReader(behavior); - result = CreateDataReader(result, _profiler); + result = CreateDbDataReader(result, _profiler); } catch (Exception e) { @@ -252,7 +252,7 @@ protected override async Task ExecuteDbDataReaderAsync(CommandBeha try { result = await _command.ExecuteReaderAsync(behavior, cancellationToken).ConfigureAwait(false); - result = CreateDataReader(result, _profiler); + result = CreateDbDataReader(result, _profiler); } catch (Exception e) {