44using System . Diagnostics ;
55using System . Diagnostics . CodeAnalysis ;
66
7- namespace KeelMatrix . QueryWatch . Ado
8- {
7+ namespace KeelMatrix . QueryWatch . Ado {
98 /// <summary>
109 /// Delegating <see cref="DbCommand"/> that measures execution and records into a session.
1110 /// </summary>
12- public sealed class QueryWatchCommand : DbCommand
13- {
11+ public sealed class QueryWatchCommand : DbCommand {
1412 private readonly DbCommand _inner ;
1513 private readonly QueryWatchSession _session ;
1614 private readonly DbConnection ? _connection ; // wrapper connection
1715
18- public QueryWatchCommand ( DbCommand inner , QueryWatchSession session , DbConnection ? wrapperConnection = null )
19- {
16+ public QueryWatchCommand ( DbCommand inner , QueryWatchSession session , DbConnection ? wrapperConnection = null ) {
2017 _inner = inner ?? throw new ArgumentNullException ( nameof ( inner ) ) ;
2118 _session = session ?? throw new ArgumentNullException ( nameof ( session ) ) ;
2219 _connection = wrapperConnection ;
2320 }
2421
2522 [ AllowNull ]
26- public override string CommandText
27- {
23+ public override string CommandText {
2824 get => _inner . CommandText ;
2925 set => _inner . CommandText = value ;
3026 }
3127
32- public override int CommandTimeout
33- {
28+ public override int CommandTimeout {
3429 get => _inner . CommandTimeout ;
3530 set => _inner . CommandTimeout = value ;
3631 }
3732
38- public override CommandType CommandType
39- {
33+ public override CommandType CommandType {
4034 get => _inner . CommandType ;
4135 set => _inner . CommandType = value ;
4236 }
4337
44- protected override DbConnection ? DbConnection
45- {
38+ protected override DbConnection ? DbConnection {
4639 get => _connection ?? _inner . Connection ;
47- set
48- {
40+ set {
4941 if ( value is null ) {
5042 _inner . Connection = null ;
5143 }
@@ -60,20 +52,17 @@ protected override DbConnection? DbConnection
6052
6153 protected override DbParameterCollection DbParameterCollection => _inner . Parameters ;
6254
63- protected override DbTransaction ? DbTransaction
64- {
55+ protected override DbTransaction ? DbTransaction {
6556 get => _inner . Transaction ;
6657 set => _inner . Transaction = value ;
6758 }
6859
69- public override bool DesignTimeVisible
70- {
60+ public override bool DesignTimeVisible {
7161 get => _inner . DesignTimeVisible ;
7262 set => _inner . DesignTimeVisible = value ;
7363 }
7464
75- public override UpdateRowSource UpdatedRowSource
76- {
65+ public override UpdateRowSource UpdatedRowSource {
7766 get => _inner . UpdatedRowSource ;
7867 set => _inner . UpdatedRowSource = value ;
7968 }
@@ -85,50 +74,43 @@ public override UpdateRowSource UpdatedRowSource
8574
8675 private void Record ( TimeSpan elapsed ) => _session . Record ( _inner . CommandText ?? string . Empty , elapsed ) ;
8776
88- public override int ExecuteNonQuery ( )
89- {
77+ public override int ExecuteNonQuery ( ) {
9078 var sw = Stopwatch . StartNew ( ) ;
9179 try { return _inner . ExecuteNonQuery ( ) ; }
9280 finally { sw . Stop ( ) ; Record ( sw . Elapsed ) ; }
9381 }
9482
95- public override object ? ExecuteScalar ( )
96- {
83+ public override object ? ExecuteScalar ( ) {
9784 var sw = Stopwatch . StartNew ( ) ;
9885 try { return _inner . ExecuteScalar ( ) ; }
9986 finally { sw . Stop ( ) ; Record ( sw . Elapsed ) ; }
10087 }
10188
102- protected override DbDataReader ExecuteDbDataReader ( CommandBehavior behavior )
103- {
89+ protected override DbDataReader ExecuteDbDataReader ( CommandBehavior behavior ) {
10490 var sw = Stopwatch . StartNew ( ) ;
10591 try { return _inner . ExecuteReader ( behavior ) ; }
10692 finally { sw . Stop ( ) ; Record ( sw . Elapsed ) ; }
10793 }
10894
109- public override async Task < int > ExecuteNonQueryAsync ( CancellationToken cancellationToken )
110- {
95+ public override async Task < int > ExecuteNonQueryAsync ( CancellationToken cancellationToken ) {
11196 var sw = Stopwatch . StartNew ( ) ;
11297 try { return await _inner . ExecuteNonQueryAsync ( cancellationToken ) . ConfigureAwait ( false ) ; }
11398 finally { sw . Stop ( ) ; Record ( sw . Elapsed ) ; }
11499 }
115100
116- public override async Task < object ? > ExecuteScalarAsync ( CancellationToken cancellationToken )
117- {
101+ public override async Task < object ? > ExecuteScalarAsync ( CancellationToken cancellationToken ) {
118102 var sw = Stopwatch . StartNew ( ) ;
119103 try { return await _inner . ExecuteScalarAsync ( cancellationToken ) . ConfigureAwait ( false ) ; }
120104 finally { sw . Stop ( ) ; Record ( sw . Elapsed ) ; }
121105 }
122106
123- protected override async Task < DbDataReader > ExecuteDbDataReaderAsync ( CommandBehavior behavior , CancellationToken cancellationToken )
124- {
107+ protected override async Task < DbDataReader > ExecuteDbDataReaderAsync ( CommandBehavior behavior , CancellationToken cancellationToken ) {
125108 var sw = Stopwatch . StartNew ( ) ;
126109 try { return await _inner . ExecuteReaderAsync ( behavior , cancellationToken ) . ConfigureAwait ( false ) ; }
127110 finally { sw . Stop ( ) ; Record ( sw . Elapsed ) ; }
128111 }
129112
130- protected override void Dispose ( bool disposing )
131- {
113+ protected override void Dispose ( bool disposing ) {
132114 if ( disposing ) _inner . Dispose ( ) ;
133115 base . Dispose ( disposing ) ;
134116 }
0 commit comments