diff --git a/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs b/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs
index d36b1fc4680..126cf071e8f 100644
--- a/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs
+++ b/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs
@@ -78,10 +78,7 @@ public static class RelationalLoggerExtensions
definition,
diagnosticSourceEnabled);
- if (interceptor != null)
- {
- return interceptor.ReaderExecuting(command, eventData, null);
- }
+ return interceptor?.ReaderExecuting(command, eventData, null);
}
return null;
@@ -127,10 +124,7 @@ public static class RelationalLoggerExtensions
definition,
diagnosticSourceEnabled);
- if (interceptor != null)
- {
- return interceptor.ScalarExecuting(command, eventData, null);
- }
+ return interceptor?.ScalarExecuting(command, eventData, null);
}
return null;
@@ -176,10 +170,7 @@ public static class RelationalLoggerExtensions
definition,
diagnosticSourceEnabled);
- if (interceptor != null)
- {
- return interceptor.NonQueryExecuting(command, eventData, null);
- }
+ return interceptor?.NonQueryExecuting(command, eventData, null);
}
return null;
@@ -1006,7 +997,7 @@ private static string CommandError(EventDefinitionBase definition, EventData pay
/// The connection.
/// The time that the operation was started.
/// The result of execution, which may have been modified by an interceptor.
- public static InterceptionResult? ConnectionOpening(
+ public static InterceptionResult? ConnectionOpening(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] IRelationalConnection connection,
DateTimeOffset startTime)
@@ -1029,10 +1020,7 @@ private static string CommandError(EventDefinitionBase definition, EventData pay
false,
diagnosticSourceEnabled);
- if (interceptor != null)
- {
- return interceptor.ConnectionOpening(connection.DbConnection, eventData, null);
- }
+ return interceptor?.ConnectionOpening(connection.DbConnection, eventData, null);
}
return null;
@@ -1418,10 +1406,7 @@ public static void ConnectionClosed(
definition,
diagnosticSourceEnabled);
- if (interceptor != null)
- {
- interceptor.ConnectionClosed(connection.DbConnection, eventData);
- }
+ interceptor?.ConnectionClosed(connection.DbConnection, eventData);
}
}
@@ -1559,10 +1544,7 @@ public static void ConnectionError(
definition,
diagnosticSourceEnabled);
- if (interceptor != null)
- {
- interceptor.ConnectionFailed(connection.DbConnection, eventData);
- }
+ interceptor?.ConnectionFailed(connection.DbConnection, eventData);
}
}
@@ -1706,10 +1688,7 @@ private static string ConnectionError(EventDefinitionBase definition, EventData
definition,
diagnosticSourceEnabled);
- if (interceptor != null)
- {
- return interceptor.TransactionStarting(connection.DbConnection, eventData, null);
- }
+ return interceptor?.TransactionStarting(connection.DbConnection, eventData, null);
}
return null;
@@ -1753,7 +1732,10 @@ private static string ConnectionError(EventDefinitionBase definition, EventData
definition,
diagnosticSourceEnabled);
- return interceptor?.TransactionStartingAsync(connection.DbConnection, eventData, null, cancellationToken);
+ if (interceptor != null)
+ {
+ return interceptor.TransactionStartingAsync(connection.DbConnection, eventData, null, cancellationToken);
+ }
}
return Task.FromResult?>(null);
@@ -2183,7 +2165,10 @@ private static string TransactionUsed(EventDefinitionBase definition, EventData
true,
diagnosticSourceEnabled);
- return interceptor?.TransactionCommittingAsync(transaction, eventData, null, cancellationToken);
+ if (interceptor != null)
+ {
+ return interceptor.TransactionCommittingAsync(transaction, eventData, null, cancellationToken);
+ }
}
return Task.FromResult(null);
@@ -2311,7 +2296,10 @@ public static Task TransactionCommittedAsync(
true,
diagnosticSourceEnabled);
- return interceptor?.TransactionCommittedAsync(transaction, eventData, cancellationToken);
+ if (interceptor != null)
+ {
+ return interceptor.TransactionCommittedAsync(transaction, eventData, cancellationToken);
+ }
}
return Task.CompletedTask;
@@ -2441,7 +2429,10 @@ public static Task TransactionRolledBackAsync(
true,
diagnosticSourceEnabled);
- return interceptor?.TransactionRolledBackAsync(transaction, eventData, cancellationToken);
+ if (interceptor != null)
+ {
+ return interceptor.TransactionRolledBackAsync(transaction, eventData, cancellationToken);
+ }
}
return Task.CompletedTask;
@@ -2568,7 +2559,10 @@ private static void LogTransactionRolledBack(
true,
diagnosticSourceEnabled);
- return interceptor?.TransactionRollingBackAsync(transaction, eventData, null, cancellationToken);
+ if (interceptor != null)
+ {
+ return interceptor.TransactionRollingBackAsync(transaction, eventData, null, cancellationToken);
+ }
}
return Task.FromResult(null);
@@ -2747,7 +2741,10 @@ public static Task TransactionErrorAsync(
true,
diagnosticSourceEnabled);
- return interceptor?.TransactionFailedAsync(transaction, eventData, cancellationToken);
+ if (interceptor != null)
+ {
+ return interceptor.TransactionFailedAsync(transaction, eventData, cancellationToken);
+ }
}
return Task.CompletedTask;