diff --git a/src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs b/src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs
index 890500fef42..9fb64135264 100644
--- a/src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs
+++ b/src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs
@@ -21,22 +21,22 @@ public abstract class DbCommandInterceptor : IDbCommandInterceptor
/// The command.
/// Contextual information about the command and execution.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will execute the command as normal.
- /// If non-null, then command execution is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// is to return the value passed in, often using
///
- public virtual InterceptionResult? ReaderExecuting(
+ public virtual InterceptionResult ReaderExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
return result;
}
@@ -47,22 +47,22 @@ public abstract class DbCommandInterceptor : IDbCommandInterceptor
/// The command.
/// Contextual information about the command and execution.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will execute the command as normal.
- /// If non-null, then command execution is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// is to return the value passed in, often using
///
- public virtual InterceptionResult? ScalarExecuting(
+ public virtual InterceptionResult ScalarExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result) => result;
+ InterceptionResult result) => result;
///
/// Called just before EF intends to call .
@@ -70,22 +70,22 @@ public abstract class DbCommandInterceptor : IDbCommandInterceptor
/// The command.
/// Contextual information about the command and execution.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will execute the command as normal.
- /// If non-null, then command execution is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// is to return the value passed in, often using
///
- public virtual InterceptionResult? NonQueryExecuting(
+ public virtual InterceptionResult NonQueryExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
=> result;
///
@@ -94,23 +94,23 @@ public abstract class DbCommandInterceptor : IDbCommandInterceptor
/// The command.
/// Contextual information about the command and execution.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will execute the command as normal.
- /// If the result is non-null value, then command execution is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the value passed in, often using
///
- public virtual Task?> ReaderExecutingAsync(
+ public virtual Task> ReaderExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
@@ -120,23 +120,23 @@ public abstract class DbCommandInterceptor : IDbCommandInterceptor
/// The command.
/// Contextual information about the command and execution.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will execute the command as normal.
- /// If the result is non-null value, then command execution is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the value passed in, often using
///
- public virtual Task?> ScalarExecutingAsync(
+ public virtual Task> ScalarExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
@@ -146,23 +146,23 @@ public abstract class DbCommandInterceptor : IDbCommandInterceptor
/// The command.
/// Contextual information about the command and execution.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will execute the command as normal.
- /// If the result is non-null value, then command execution is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the value passed in, often using
///
- public virtual Task?> NonQueryExecutingAsync(
+ public virtual Task> NonQueryExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
@@ -358,21 +358,22 @@ public virtual Task CommandFailedAsync(
/// The command.
/// Contextual information about the command and reader.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will dispose the reader as normal.
- /// If non-null, then disposing the reader is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- public virtual InterceptionResult? DataReaderDisposing(
+ public virtual InterceptionResult DataReaderDisposing(
DbCommand command,
DataReaderDisposingEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
=> result;
}
}
diff --git a/src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs b/src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs
index cfa7b9f92b3..1657ed921ab 100644
--- a/src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs
+++ b/src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs
@@ -21,21 +21,22 @@ public abstract class DbConnectionInterceptor : IDbConnectionInterceptor
/// The connection.
/// Contextual information about the connection.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will open the connection as normal.
- /// If non-null, then connection opening is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- public virtual InterceptionResult? ConnectionOpening(
+ public virtual InterceptionResult ConnectionOpening(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
=> result;
///
@@ -44,22 +45,23 @@ public abstract class DbConnectionInterceptor : IDbConnectionInterceptor
/// The connection.
/// Contextual information about the connection.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will open the connection as normal.
- /// If the result is non-null value, then connection opening is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in, often using
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- public virtual Task ConnectionOpeningAsync(
+ public virtual Task ConnectionOpeningAsync(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
@@ -91,21 +93,22 @@ public virtual Task ConnectionOpenedAsync(
/// The connection.
/// Contextual information about the connection.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will close the connection as normal.
- /// If non-null, then connection closing is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- public virtual InterceptionResult? ConnectionClosing(
+ public virtual InterceptionResult ConnectionClosing(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
=> result;
///
@@ -114,21 +117,22 @@ public virtual Task ConnectionOpenedAsync(
/// The connection.
/// Contextual information about the connection.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If the result is null, then EF will close the connection as normal.
- /// If the result is non-null value, then connection closing is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in, often using
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- public virtual Task ConnectionClosingAsync(
+ public virtual Task ConnectionClosingAsync(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
=> Task.FromResult(result);
///
diff --git a/src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs b/src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs
index 8c23fca24b2..e231bc47bee 100644
--- a/src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs
+++ b/src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs
@@ -22,22 +22,22 @@ public abstract class DbTransactionInterceptor : IDbTransactionInterceptor
/// The connection.
/// Contextual information about connection and transaction.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed creation by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will start the transaction as normal.
- /// If non-null, then transaction creation is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// is to return the value passed in, often using
///
- public virtual InterceptionResult? TransactionStarting(
+ public virtual InterceptionResult TransactionStarting(
DbConnection connection,
TransactionStartingEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
=> result;
///
@@ -72,21 +72,21 @@ public virtual DbTransaction TransactionStarted(
/// The connection.
/// Contextual information about connection and transaction.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed creation by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will start the transaction as normal.
- /// If the result is non-null value, then transaction creation is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the value passed in, often using
///
- public virtual Task?> TransactionStartingAsync(
- DbConnection connection, TransactionStartingEventData eventData, InterceptionResult? result,
+ public virtual Task> TransactionStartingAsync(
+ DbConnection connection, TransactionStartingEventData eventData, InterceptionResult result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
@@ -168,21 +168,22 @@ public virtual Task TransactionUsedAsync(
/// The transaction.
/// Contextual information about connection and transaction.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed committing by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will committing the transaction as normal.
- /// If non-null, then committing the transaction is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- public virtual InterceptionResult? TransactionCommitting(
+ public virtual InterceptionResult TransactionCommitting(
DbTransaction transaction,
TransactionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
=> result;
///
@@ -202,22 +203,23 @@ public virtual void TransactionCommitted(
/// The transaction.
/// Contextual information about connection and transaction.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed committing returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will commit the transaction as normal.
- /// If the result is non-null value, committing the transaction is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in, often using
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- public virtual Task TransactionCommittingAsync(
+ public virtual Task TransactionCommittingAsync(
DbTransaction transaction,
TransactionEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
@@ -240,21 +242,22 @@ public virtual Task TransactionCommittedAsync(
/// The transaction.
/// Contextual information about connection and transaction.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed rolling back by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will roll back the transaction as normal.
- /// If non-null, then rolling back the transaction is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- public virtual InterceptionResult? TransactionRollingBack(
+ public virtual InterceptionResult TransactionRollingBack(
DbTransaction transaction,
TransactionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
=> result;
///
@@ -274,22 +277,23 @@ public virtual void TransactionRolledBack(
/// The transaction.
/// Contextual information about connection and transaction.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed rolling back returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will roll back the transaction as normal.
- /// If the result is non-null value, rolling back the transaction is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in, often using
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- public virtual Task TransactionRollingBackAsync(
+ public virtual Task TransactionRollingBackAsync(
DbTransaction transaction,
TransactionEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
diff --git a/src/EFCore.Relational/Diagnostics/IDbCommandInterceptor.cs b/src/EFCore.Relational/Diagnostics/IDbCommandInterceptor.cs
index df8ac2a9e62..7d2c75cd433 100644
--- a/src/EFCore.Relational/Diagnostics/IDbCommandInterceptor.cs
+++ b/src/EFCore.Relational/Diagnostics/IDbCommandInterceptor.cs
@@ -37,22 +37,22 @@ public interface IDbCommandInterceptor : IInterceptor
/// The command.
/// Contextual information about the command and execution.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will execute the command as normal.
- /// If non-null, then command execution is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the value passed in.
///
- InterceptionResult? ReaderExecuting(
+ InterceptionResult ReaderExecuting(
[NotNull] DbCommand command,
[NotNull] CommandEventData eventData,
- InterceptionResult? result);
+ InterceptionResult result);
///
/// Called just before EF intends to call .
@@ -60,22 +60,22 @@ public interface IDbCommandInterceptor : IInterceptor
/// The command.
/// Contextual information about the command and execution.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will execute the command as normal.
- /// If non-null, then command execution is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the value passed in.
///
- InterceptionResult? ScalarExecuting(
+ InterceptionResult ScalarExecuting(
[NotNull] DbCommand command,
[NotNull] CommandEventData eventData,
- InterceptionResult? result);
+ InterceptionResult result);
///
/// Called just before EF intends to call .
@@ -83,22 +83,22 @@ public interface IDbCommandInterceptor : IInterceptor
/// The command.
/// Contextual information about the command and execution.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will execute the command as normal.
- /// If non-null, then command execution is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the value passed in.
///
- InterceptionResult? NonQueryExecuting(
+ InterceptionResult NonQueryExecuting(
[NotNull] DbCommand command,
[NotNull] CommandEventData eventData,
- InterceptionResult? result);
+ InterceptionResult result);
///
/// Called just before EF intends to call .
@@ -106,23 +106,23 @@ public interface IDbCommandInterceptor : IInterceptor
/// The command.
/// Contextual information about the command and execution.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will execute the command as normal.
- /// If the result is non-null value, then command execution is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the value passed in, often using
///
- Task?> ReaderExecutingAsync(
+ Task> ReaderExecutingAsync(
[NotNull] DbCommand command,
[NotNull] CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default);
///
@@ -131,23 +131,23 @@ public interface IDbCommandInterceptor : IInterceptor
/// The command.
/// Contextual information about the command and execution.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will execute the command as normal.
- /// If the result is non-null value, then command execution is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the value passed in, often using
///
- Task?> ScalarExecutingAsync(
+ Task> ScalarExecutingAsync(
[NotNull] DbCommand command,
[NotNull] CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default);
///
@@ -156,23 +156,23 @@ public interface IDbCommandInterceptor : IInterceptor
/// The command.
/// Contextual information about the command and execution.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will execute the command as normal.
- /// If the result is non-null value, then command execution is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the value passed in, often using
///
- Task?> NonQueryExecutingAsync(
+ Task> NonQueryExecutingAsync(
[NotNull] DbCommand command,
[NotNull] CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default);
///
@@ -358,20 +358,21 @@ Task CommandFailedAsync(
/// The command.
/// Contextual information about the command and reader.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will dispose the reader as normal.
- /// If non-null, then disposing the reader is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- InterceptionResult? DataReaderDisposing(
+ InterceptionResult DataReaderDisposing(
[NotNull] DbCommand command,
[NotNull] DataReaderDisposingEventData eventData,
- InterceptionResult? result);
+ InterceptionResult result);
}
}
diff --git a/src/EFCore.Relational/Diagnostics/IDbConnectionInterceptor.cs b/src/EFCore.Relational/Diagnostics/IDbConnectionInterceptor.cs
index 6b3cb476e32..69bfbfc5575 100644
--- a/src/EFCore.Relational/Diagnostics/IDbConnectionInterceptor.cs
+++ b/src/EFCore.Relational/Diagnostics/IDbConnectionInterceptor.cs
@@ -37,21 +37,22 @@ public interface IDbConnectionInterceptor : IInterceptor
/// The connection.
/// Contextual information about the connection.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will open the connection as normal.
- /// If non-null, then connection opening is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- InterceptionResult? ConnectionOpening(
+ InterceptionResult ConnectionOpening(
[NotNull] DbConnection connection,
[NotNull] ConnectionEventData eventData,
- InterceptionResult? result);
+ InterceptionResult result);
///
/// Called just before EF intends to call .
@@ -59,22 +60,23 @@ public interface IDbConnectionInterceptor : IInterceptor
/// The connection.
/// Contextual information about the connection.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will open the connection as normal.
- /// If the result is non-null value, then connection opening is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in, often using
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- Task ConnectionOpeningAsync(
+ Task ConnectionOpeningAsync(
[NotNull] DbConnection connection,
[NotNull] ConnectionEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default);
///
@@ -104,21 +106,22 @@ Task ConnectionOpenedAsync(
/// The connection.
/// Contextual information about the connection.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will close the connection as normal.
- /// If non-null, then connection closing is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- InterceptionResult? ConnectionClosing(
+ InterceptionResult ConnectionClosing(
[NotNull] DbConnection connection,
[NotNull] ConnectionEventData eventData,
- InterceptionResult? result);
+ InterceptionResult result);
///
/// Called just before EF intends to call in an async context.
@@ -126,21 +129,22 @@ Task ConnectionOpenedAsync(
/// The connection.
/// Contextual information about the connection.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed execution by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If the result is null, then EF will close the connection as normal.
- /// If the result is non-null value, then connection closing is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in, often using
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- Task ConnectionClosingAsync(
+ Task ConnectionClosingAsync(
[NotNull] DbConnection connection,
[NotNull] ConnectionEventData eventData,
- InterceptionResult? result);
+ InterceptionResult result);
///
/// Called just after EF has called in an async context.
diff --git a/src/EFCore.Relational/Diagnostics/IDbTransactionInterceptor.cs b/src/EFCore.Relational/Diagnostics/IDbTransactionInterceptor.cs
index 9e4bd358883..262d2e72fb4 100644
--- a/src/EFCore.Relational/Diagnostics/IDbTransactionInterceptor.cs
+++ b/src/EFCore.Relational/Diagnostics/IDbTransactionInterceptor.cs
@@ -39,22 +39,22 @@ public interface IDbTransactionInterceptor : IInterceptor
/// The connection.
/// Contextual information about connection and transaction.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed creation by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will start the transaction as normal.
- /// If non-null, then transaction creation is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// is to return the value passed in, often using
///
- InterceptionResult? TransactionStarting(
+ InterceptionResult TransactionStarting(
[NotNull] DbConnection connection,
[NotNull] TransactionStartingEventData eventData,
- InterceptionResult? result);
+ InterceptionResult result);
///
///
@@ -87,23 +87,23 @@ DbTransaction TransactionStarted(
/// The connection.
/// Contextual information about connection and transaction.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed creation by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will start the transaction as normal.
- /// If the result is non-null value, then transaction creation is suppressed and the value contained in
- /// the we be used by EF instead.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation it
+ /// was about to perform and use instead.
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the value passed in, often using
///
- Task?> TransactionStartingAsync(
+ Task> TransactionStartingAsync(
[NotNull] DbConnection connection,
[NotNull] TransactionStartingEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default);
///
@@ -184,21 +184,22 @@ Task TransactionUsedAsync(
/// The transaction.
/// Contextual information about connection and transaction.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed committing by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will committing the transaction as normal.
- /// If non-null, then committing the transaction is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- InterceptionResult? TransactionCommitting(
+ InterceptionResult TransactionCommitting(
[NotNull] DbTransaction transaction,
[NotNull] TransactionEventData eventData,
- InterceptionResult? result);
+ InterceptionResult result);
///
/// Called immediately after EF calls .
@@ -215,22 +216,23 @@ void TransactionCommitted(
/// The transaction.
/// Contextual information about connection and transaction.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed committing returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will commit the transaction as normal.
- /// If the result is non-null value, committing the transaction is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in, often using
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- Task TransactionCommittingAsync(
+ Task TransactionCommittingAsync(
[NotNull] DbTransaction transaction,
[NotNull] TransactionEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default);
///
@@ -251,21 +253,22 @@ Task TransactionCommittedAsync(
/// The transaction.
/// Contextual information about connection and transaction.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed rolling back by returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
///
- /// If null, then EF will roll back the transaction as normal.
- /// If non-null, then rolling back the transaction is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in.
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- InterceptionResult? TransactionRollingBack(
+ InterceptionResult TransactionRollingBack(
[NotNull] DbTransaction transaction,
[NotNull] TransactionEventData eventData,
- InterceptionResult? result);
+ InterceptionResult result);
///
/// Called immediately after EF calls .
@@ -282,22 +285,23 @@ void TransactionRolledBack(
/// The transaction.
/// Contextual information about connection and transaction.
///
- /// The current result, or null if no result yet exists.
- /// This value will be non-null if some previous interceptor suppressed rolling back returning a result from
- /// its implementation of this method.
+ /// Represents the current result if one exists.
+ /// This value will have set to true if some previous
+ /// interceptor suppressed execution by calling .
/// This value is typically used as the return value for the implementation of this method.
///
/// The cancellation token.
///
- /// If the result is null, then EF will roll back the transaction as normal.
- /// If the result is non-null value, rolling back the transaction is suppressed.
- /// A normal implementation of this method for any interceptor that is not attempting to change the result
- /// is to return the value passed in, often using
+ /// If is false, the EF will continue as normal.
+ /// If is true, then EF will suppress the operation
+ /// it was about to perform.
+ /// A normal implementation of this method for any interceptor that is not attempting to suppress
+ /// the operation is to return the value passed in.
///
- Task TransactionRollingBackAsync(
+ Task TransactionRollingBackAsync(
[NotNull] DbTransaction transaction,
[NotNull] TransactionEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default);
///
diff --git a/src/EFCore.Relational/Diagnostics/Internal/DbCommandInterceptorResolver.cs b/src/EFCore.Relational/Diagnostics/Internal/DbCommandInterceptorResolver.cs
index 487a125ca94..e5dad592494 100644
--- a/src/EFCore.Relational/Diagnostics/Internal/DbCommandInterceptorResolver.cs
+++ b/src/EFCore.Relational/Diagnostics/Internal/DbCommandInterceptorResolver.cs
@@ -36,10 +36,10 @@ public CompositeDbCommandInterceptor([NotNull] IEnumerable? ReaderExecuting(
+ public InterceptionResult ReaderExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
for (var i = 0; i < _interceptors.Length; i++)
{
@@ -49,10 +49,10 @@ public CompositeDbCommandInterceptor([NotNull] IEnumerable? ScalarExecuting(
+ public InterceptionResult ScalarExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
for (var i = 0; i < _interceptors.Length; i++)
{
@@ -62,10 +62,10 @@ public CompositeDbCommandInterceptor([NotNull] IEnumerable? NonQueryExecuting(
+ public InterceptionResult NonQueryExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
for (var i = 0; i < _interceptors.Length; i++)
{
@@ -75,10 +75,10 @@ public CompositeDbCommandInterceptor([NotNull] IEnumerable?> ReaderExecutingAsync(
+ public async Task> ReaderExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
for (var i = 0; i < _interceptors.Length; i++)
@@ -89,10 +89,10 @@ public CompositeDbCommandInterceptor([NotNull] IEnumerable?> ScalarExecutingAsync(
+ public async Task> ScalarExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
for (var i = 0; i < _interceptors.Length; i++)
@@ -103,10 +103,10 @@ public CompositeDbCommandInterceptor([NotNull] IEnumerable?> NonQueryExecutingAsync(
+ public async Task> NonQueryExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
for (var i = 0; i < _interceptors.Length; i++)
@@ -215,10 +215,10 @@ public async Task CommandFailedAsync(
}
}
- public InterceptionResult? DataReaderDisposing(
+ public InterceptionResult DataReaderDisposing(
DbCommand command,
DataReaderDisposingEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
for (var i = 0; i < _interceptors.Length; i++)
{
diff --git a/src/EFCore.Relational/Diagnostics/Internal/DbConnectionInterceptorResolver.cs b/src/EFCore.Relational/Diagnostics/Internal/DbConnectionInterceptorResolver.cs
index 0df476dbb68..15bc2ef5848 100644
--- a/src/EFCore.Relational/Diagnostics/Internal/DbConnectionInterceptorResolver.cs
+++ b/src/EFCore.Relational/Diagnostics/Internal/DbConnectionInterceptorResolver.cs
@@ -36,10 +36,10 @@ public CompositeDbConnectionInterceptor([NotNull] IEnumerable ConnectionOpeningAsync(
+ public async Task ConnectionOpeningAsync(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
for (var i = 0; i < _interceptors.Length; i++)
@@ -84,10 +84,10 @@ public async Task ConnectionOpenedAsync(
}
}
- public InterceptionResult? ConnectionClosing(
+ public InterceptionResult ConnectionClosing(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
for (var i = 0; i < _interceptors.Length; i++)
{
@@ -97,10 +97,10 @@ public async Task ConnectionOpenedAsync(
return result;
}
- public async Task ConnectionClosingAsync(
+ public async Task ConnectionClosingAsync(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
for (var i = 0; i < _interceptors.Length; i++)
{
diff --git a/src/EFCore.Relational/Diagnostics/Internal/DbTransactionInterceptorResolver.cs b/src/EFCore.Relational/Diagnostics/Internal/DbTransactionInterceptorResolver.cs
index 15c2803b692..4195901bf78 100644
--- a/src/EFCore.Relational/Diagnostics/Internal/DbTransactionInterceptorResolver.cs
+++ b/src/EFCore.Relational/Diagnostics/Internal/DbTransactionInterceptorResolver.cs
@@ -36,10 +36,10 @@ public CompositeDbTransactionInterceptor([NotNull] IEnumerable? TransactionStarting(
+ public InterceptionResult TransactionStarting(
DbConnection connection,
TransactionStartingEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
for (var i = 0; i < _interceptors.Length; i++)
{
@@ -62,10 +62,10 @@ public DbTransaction TransactionStarted(
return result;
}
- public async Task?> TransactionStartingAsync(
+ public async Task> TransactionStartingAsync(
DbConnection connection,
TransactionStartingEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
for (var i = 0; i < _interceptors.Length; i++)
@@ -117,10 +117,10 @@ public async Task TransactionUsedAsync(
return result;
}
- public InterceptionResult? TransactionCommitting(
+ public InterceptionResult TransactionCommitting(
DbTransaction transaction,
TransactionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
for (var i = 0; i < _interceptors.Length; i++)
{
@@ -140,10 +140,10 @@ public void TransactionCommitted(
}
}
- public async Task TransactionCommittingAsync(
+ public async Task TransactionCommittingAsync(
DbTransaction transaction,
TransactionEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
for (var i = 0; i < _interceptors.Length; i++)
@@ -165,10 +165,10 @@ public async Task TransactionCommittedAsync(
}
}
- public InterceptionResult? TransactionRollingBack(
+ public InterceptionResult TransactionRollingBack(
DbTransaction transaction,
TransactionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
for (var i = 0; i < _interceptors.Length; i++)
{
@@ -188,10 +188,10 @@ public void TransactionRolledBack(
}
}
- public async Task TransactionRollingBackAsync(
+ public async Task TransactionRollingBackAsync(
DbTransaction transaction,
TransactionEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
for (var i = 0; i < _interceptors.Length; i++)
diff --git a/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs b/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs
index d9f7cd5b044..59a74cafbd7 100644
--- a/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs
+++ b/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs
@@ -47,8 +47,8 @@ public static class RelationalLoggerExtensions
/// The correlation ID associated with the given .
/// The correlation ID associated with the being used.
/// The time that execution began.
- /// An intercepted result, or null if the result was not intercepted.
- public static InterceptionResult? CommandReaderExecuting(
+ /// An intercepted result.
+ public static InterceptionResult CommandReaderExecuting(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] DbCommand command,
[CanBeNull] DbContext context,
@@ -78,10 +78,13 @@ public static class RelationalLoggerExtensions
definition,
diagnosticSourceEnabled);
- return interceptor?.ReaderExecuting(command, eventData, null);
+ if (interceptor != null)
+ {
+ return interceptor.ReaderExecuting(command, eventData, default);
+ }
}
- return null;
+ return default;
}
///
@@ -93,8 +96,8 @@ public static class RelationalLoggerExtensions
/// The correlation ID associated with the given .
/// The correlation ID associated with the being used.
/// The time that execution began.
- /// An intercepted result, or null if the result was not intercepted.
- public static InterceptionResult? CommandScalarExecuting(
+ /// An intercepted result.
+ public static InterceptionResult CommandScalarExecuting(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] DbCommand command,
[CanBeNull] DbContext context,
@@ -124,10 +127,13 @@ public static class RelationalLoggerExtensions
definition,
diagnosticSourceEnabled);
- return interceptor?.ScalarExecuting(command, eventData, null);
+ if (interceptor != null)
+ {
+ return interceptor.ScalarExecuting(command, eventData, default);
+ }
}
- return null;
+ return default;
}
///
@@ -139,8 +145,8 @@ public static class RelationalLoggerExtensions
/// The correlation ID associated with the given .
/// The correlation ID associated with the being used.
/// The time that execution began.
- /// An intercepted result, or null if the result was not intercepted.
- public static InterceptionResult? CommandNonQueryExecuting(
+ /// An intercepted result.
+ public static InterceptionResult CommandNonQueryExecuting(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] DbCommand command,
[CanBeNull] DbContext context,
@@ -170,10 +176,13 @@ public static class RelationalLoggerExtensions
definition,
diagnosticSourceEnabled);
- return interceptor?.NonQueryExecuting(command, eventData, null);
+ if (interceptor != null)
+ {
+ return interceptor.NonQueryExecuting(command, eventData, default);
+ }
}
- return null;
+ return default;
}
///
@@ -186,8 +195,8 @@ public static class RelationalLoggerExtensions
/// The correlation ID associated with the being used.
/// The time that execution began.
/// The cancellation token.
- /// An intercepted result, or null if the result was not intercepted.
- public static Task?> CommandReaderExecutingAsync(
+ /// An intercepted result.
+ public static Task> CommandReaderExecutingAsync(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] DbCommand command,
[CanBeNull] DbContext context,
@@ -220,11 +229,11 @@ public static class RelationalLoggerExtensions
if (interceptor != null)
{
- return interceptor.ReaderExecutingAsync(command, eventData, null, cancellationToken);
+ return interceptor.ReaderExecutingAsync(command, eventData, default, cancellationToken);
}
}
- return Task.FromResult?>(null);
+ return Task.FromResult(default(InterceptionResult));
}
///
@@ -237,8 +246,8 @@ public static class RelationalLoggerExtensions
/// The correlation ID associated with the being used.
/// The time that execution began.
/// The cancellation token.
- /// An intercepted result, or null if the result was not intercepted.
- public static Task?> CommandScalarExecutingAsync(
+ /// An intercepted result.
+ public static Task> CommandScalarExecutingAsync(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] DbCommand command,
[CanBeNull] DbContext context,
@@ -271,11 +280,11 @@ public static class RelationalLoggerExtensions
if (interceptor != null)
{
- return interceptor.ScalarExecutingAsync(command, eventData, null, cancellationToken);
+ return interceptor.ScalarExecutingAsync(command, eventData, default, cancellationToken);
}
}
- return Task.FromResult?>(null);
+ return Task.FromResult(default(InterceptionResult));
}
///
@@ -288,8 +297,8 @@ public static class RelationalLoggerExtensions
/// The correlation ID associated with the being used.
/// The time that execution began.
/// The cancellation token.
- /// An intercepted result, or null if the result was not intercepted.
- public static Task?> CommandNonQueryExecutingAsync(
+ /// An intercepted result.
+ public static Task> CommandNonQueryExecutingAsync(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] DbCommand command,
[CanBeNull] DbContext context,
@@ -322,11 +331,11 @@ public static class RelationalLoggerExtensions
if (interceptor != null)
{
- return interceptor.NonQueryExecutingAsync(command, eventData, null, cancellationToken);
+ return interceptor.NonQueryExecutingAsync(command, eventData, default, cancellationToken);
}
}
- return Task.FromResult?>(null);
+ return Task.FromResult(default(InterceptionResult));
}
private static CommandEventData BroadcastCommandExecuting(
@@ -997,7 +1006,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)
@@ -1020,10 +1029,13 @@ private static string CommandError(EventDefinitionBase definition, EventData pay
false,
diagnosticSourceEnabled);
- return interceptor?.ConnectionOpening(connection.DbConnection, eventData, null);
+ if (interceptor != null)
+ {
+ return interceptor.ConnectionOpening(connection.DbConnection, eventData,default);
+ }
}
- return null;
+ return default;
}
///
@@ -1034,7 +1046,7 @@ private static string CommandError(EventDefinitionBase definition, EventData pay
/// The time that the operation was started.
/// The cancellation token.
/// A representing the async operation.
- public static Task ConnectionOpeningAsync(
+ public static Task ConnectionOpeningAsync(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] IRelationalConnection connection,
DateTimeOffset startTime,
@@ -1060,11 +1072,11 @@ private static string CommandError(EventDefinitionBase definition, EventData pay
if (interceptor != null)
{
- return interceptor.ConnectionOpeningAsync(connection.DbConnection, eventData, null, cancellationToken);
+ return interceptor.ConnectionOpeningAsync(connection.DbConnection, eventData, default, cancellationToken);
}
}
- return Task.FromResult(null);
+ return Task.FromResult(default(InterceptionResult));
}
private static void LogConnectionOpening(
@@ -1255,7 +1267,7 @@ private static string ConnectionOpened(EventDefinitionBase definition, EventData
/// The connection.
/// The time that the operation was started.
/// The result of execution, which may have been modified by an interceptor.
- public static InterceptionResult? ConnectionClosing(
+ public static InterceptionResult ConnectionClosing(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] IRelationalConnection connection,
DateTimeOffset startTime)
@@ -1278,10 +1290,13 @@ private static string ConnectionOpened(EventDefinitionBase definition, EventData
definition,
diagnosticSourceEnabled);
- return interceptor?.ConnectionClosing(connection.DbConnection, eventData, null);
+ if (interceptor != null)
+ {
+ return interceptor.ConnectionClosing(connection.DbConnection, eventData, default);
+ }
}
- return null;
+ return default;
}
///
@@ -1291,7 +1306,7 @@ private static string ConnectionOpened(EventDefinitionBase definition, EventData
/// The connection.
/// The time that the operation was started.
/// A representing the async operation.
- public static Task ConnectionClosingAsync(
+ public static Task ConnectionClosingAsync(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] IRelationalConnection connection,
DateTimeOffset startTime)
@@ -1316,11 +1331,11 @@ private static string ConnectionOpened(EventDefinitionBase definition, EventData
if (interceptor != null)
{
- return interceptor.ConnectionClosingAsync(connection.DbConnection, eventData, null);
+ return interceptor.ConnectionClosingAsync(connection.DbConnection, eventData, default);
}
}
- return Task.FromResult(null);
+ return Task.FromResult(default(InterceptionResult));
}
private static ConnectionEventData BroadcastConnectionClosing(
@@ -1657,7 +1672,7 @@ private static string ConnectionError(EventDefinitionBase definition, EventData
/// The correlation ID associated with the .
/// The time that the operation was started.
/// The result of execution, which may have been modified by an interceptor.
- public static InterceptionResult? TransactionStarting(
+ public static InterceptionResult TransactionStarting(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] IRelationalConnection connection,
IsolationLevel isolationLevel,
@@ -1684,10 +1699,13 @@ private static string ConnectionError(EventDefinitionBase definition, EventData
definition,
diagnosticSourceEnabled);
- return interceptor?.TransactionStarting(connection.DbConnection, eventData, null);
+ if (interceptor != null)
+ {
+ return interceptor.TransactionStarting(connection.DbConnection, eventData, default);
+ }
}
- return null;
+ return default;
}
///
@@ -1700,7 +1718,7 @@ private static string ConnectionError(EventDefinitionBase definition, EventData
/// The time that the operation was started.
/// The cancellation token.
/// The result of execution, which may have been modified by an interceptor.
- public static Task?> TransactionStartingAsync(
+ public static Task> TransactionStartingAsync(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] IRelationalConnection connection,
IsolationLevel isolationLevel,
@@ -1730,11 +1748,11 @@ private static string ConnectionError(EventDefinitionBase definition, EventData
if (interceptor != null)
{
- return interceptor.TransactionStartingAsync(connection.DbConnection, eventData, null, cancellationToken);
+ return interceptor.TransactionStartingAsync(connection.DbConnection, eventData, default, cancellationToken);
}
}
- return Task.FromResult?>(null);
+ return Task.FromResult(default(InterceptionResult));
}
private static TransactionStartingEventData BroadcastTransactionStarting(
@@ -2090,7 +2108,7 @@ private static string TransactionUsed(EventDefinitionBase definition, EventData
/// The correlation ID associated with the .
/// The time that the operation was started.
/// The result of execution, which may have been modified by an interceptor.
- public static InterceptionResult? TransactionCommitting(
+ public static InterceptionResult TransactionCommitting(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] IRelationalConnection connection,
[NotNull] DbTransaction transaction,
@@ -2117,10 +2135,13 @@ private static string TransactionUsed(EventDefinitionBase definition, EventData
false,
diagnosticSourceEnabled);
- return interceptor?.TransactionCommitting(transaction, eventData, null);
+ if (interceptor != null)
+ {
+ return interceptor.TransactionCommitting(transaction, eventData, default);
+ }
}
- return null;
+ return default;
}
///
@@ -2133,7 +2154,7 @@ private static string TransactionUsed(EventDefinitionBase definition, EventData
/// The time that the operation was started.
/// The cancellation token.
/// A representing the async operation.
- public static Task TransactionCommittingAsync(
+ public static Task TransactionCommittingAsync(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] IRelationalConnection connection,
[NotNull] DbTransaction transaction,
@@ -2163,11 +2184,11 @@ private static string TransactionUsed(EventDefinitionBase definition, EventData
if (interceptor != null)
{
- return interceptor.TransactionCommittingAsync(transaction, eventData, null, cancellationToken);
+ return interceptor.TransactionCommittingAsync(transaction, eventData, default, cancellationToken);
}
}
- return Task.FromResult(null);
+ return Task.FromResult(default(InterceptionResult));
}
private static TransactionEventData BroadcastTransactionCommitting(
@@ -2484,7 +2505,7 @@ private static void LogTransactionRolledBack(
/// The correlation ID associated with the .
/// The time that the operation was started.
/// The result of execution, which may have been modified by an interceptor.
- public static InterceptionResult? TransactionRollingBack(
+ public static InterceptionResult TransactionRollingBack(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] IRelationalConnection connection,
[NotNull] DbTransaction transaction,
@@ -2511,10 +2532,13 @@ private static void LogTransactionRolledBack(
false,
diagnosticSourceEnabled);
- return interceptor?.TransactionRollingBack(transaction, eventData, null);
+ if (interceptor != null)
+ {
+ return interceptor.TransactionRollingBack(transaction, eventData, default);
+ }
}
- return null;
+ return default;
}
///
@@ -2527,7 +2551,7 @@ private static void LogTransactionRolledBack(
/// The time that the operation was started.
/// The cancellation token.
/// A representing the async operation.
- public static Task TransactionRollingBackAsync(
+ public static Task TransactionRollingBackAsync(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] IRelationalConnection connection,
[NotNull] DbTransaction transaction,
@@ -2557,11 +2581,11 @@ private static void LogTransactionRolledBack(
if (interceptor != null)
{
- return interceptor.TransactionRollingBackAsync(transaction, eventData, null, cancellationToken);
+ return interceptor.TransactionRollingBackAsync(transaction, eventData, default, cancellationToken);
}
}
- return Task.FromResult(null);
+ return Task.FromResult(default(InterceptionResult));
}
private static TransactionEventData BroadcastTransactionRollingBack(
@@ -2923,7 +2947,7 @@ private static string ExplicitTransactionEnlisted(EventDefinitionBase definition
/// The time that the operation was started.
/// The elapsed time from when the operation was started.
/// The result of execution, which may have been modified by an interceptor.
- public static InterceptionResult? DataReaderDisposing(
+ public static InterceptionResult DataReaderDisposing(
[NotNull] this IDiagnosticsLogger diagnostics,
[NotNull] IRelationalConnection connection,
[NotNull] DbCommand command,
@@ -2968,10 +2992,13 @@ private static string ExplicitTransactionEnlisted(EventDefinitionBase definition
eventData);
}
- return interceptor?.DataReaderDisposing(command, eventData, null);
+ if (interceptor != null)
+ {
+ return interceptor.DataReaderDisposing(command, eventData, default);
+ }
}
- return null;
+ return default;
}
///
diff --git a/src/EFCore.Relational/Storage/RelationalCommand.cs b/src/EFCore.Relational/Storage/RelationalCommand.cs
index daa37af082b..1e6f83fb949 100644
--- a/src/EFCore.Relational/Storage/RelationalCommand.cs
+++ b/src/EFCore.Relational/Storage/RelationalCommand.cs
@@ -84,13 +84,17 @@ public virtual int ExecuteNonQuery(RelationalCommandParameterObject parameterObj
var stopwatch = Stopwatch.StartNew();
try
{
- var nonQueryResult = (logger?.CommandNonQueryExecuting(
- command,
- context,
- commandId,
- connection.ConnectionId,
- startTime: startTime)
- ?? new InterceptionResult(command.ExecuteNonQuery())).Result;
+ var interceptionResult = logger?.CommandNonQueryExecuting(
+ command,
+ context,
+ commandId,
+ connection.ConnectionId,
+ startTime)
+ ?? default;
+
+ var nonQueryResult = interceptionResult.HasResult
+ ? interceptionResult.Result
+ : command.ExecuteNonQuery();
return logger?.CommandNonQueryExecuted(
command,
@@ -165,7 +169,7 @@ public virtual async Task ExecuteNonQueryAsync(
try
{
var interceptionResult = logger == null
- ? null
+ ? default
: await logger.CommandNonQueryExecutingAsync(
command,
context,
@@ -174,8 +178,8 @@ public virtual async Task ExecuteNonQueryAsync(
startTime,
cancellationToken);
- var result = interceptionResult.HasValue
- ? interceptionResult.Value.Result
+ var result = interceptionResult.HasResult
+ ? interceptionResult.Result
: await command.ExecuteNonQueryAsync(cancellationToken);
if (logger != null)
@@ -235,13 +239,17 @@ public virtual object ExecuteScalar(RelationalCommandParameterObject parameterOb
var stopwatch = Stopwatch.StartNew();
try
{
- var result = (logger?.CommandScalarExecuting(
- command,
- context,
- commandId,
- connection.ConnectionId,
- startTime)
- ?? new InterceptionResult(command.ExecuteScalar())).Result;
+ var interceptionResult = logger?.CommandScalarExecuting(
+ command,
+ context,
+ commandId,
+ connection.ConnectionId,
+ startTime)
+ ?? default;
+
+ var result = interceptionResult.HasResult
+ ? interceptionResult.Result
+ : command.ExecuteScalar();
return logger?.CommandScalarExecuted(
command,
@@ -298,7 +306,7 @@ public virtual async Task ExecuteScalarAsync(
try
{
var interceptionResult = logger == null
- ? null
+ ? default
: await logger.CommandScalarExecutingAsync(
command,
context,
@@ -307,8 +315,8 @@ public virtual async Task ExecuteScalarAsync(
startTime,
cancellationToken);
- var result = interceptionResult.HasValue
- ? interceptionResult.Value.Result
+ var result = interceptionResult.HasResult
+ ? interceptionResult.Result
: await command.ExecuteScalarAsync(cancellationToken);
if (logger != null)
@@ -370,13 +378,17 @@ public virtual RelationalDataReader ExecuteReader(RelationalCommandParameterObje
var readerOpen = false;
try
{
- var reader = (logger?.CommandReaderExecuting(
- command,
- context,
- commandId,
- connection.ConnectionId,
- startTime)
- ?? new InterceptionResult(command.ExecuteReader())).Result;
+ var interceptionResult = logger?.CommandReaderExecuting(
+ command,
+ context,
+ commandId,
+ connection.ConnectionId,
+ startTime)
+ ?? default;
+
+ var reader = interceptionResult.HasResult
+ ? interceptionResult.Result
+ : command.ExecuteReader();
if (logger != null)
{
@@ -450,7 +462,7 @@ public virtual async Task ExecuteReaderAsync(
try
{
var interceptionResult = logger == null
- ? null
+ ? default
: await logger.CommandReaderExecutingAsync(
command,
context,
@@ -459,8 +471,8 @@ public virtual async Task ExecuteReaderAsync(
startTime,
cancellationToken);
- var reader = interceptionResult.HasValue
- ? interceptionResult.Value.Result
+ var reader = interceptionResult.HasResult
+ ? interceptionResult.Result
: await command.ExecuteReaderAsync(cancellationToken);
if (logger != null)
diff --git a/src/EFCore.Relational/Storage/RelationalConnection.cs b/src/EFCore.Relational/Storage/RelationalConnection.cs
index e604fd3c0f6..17f384f3d96 100644
--- a/src/EFCore.Relational/Storage/RelationalConnection.cs
+++ b/src/EFCore.Relational/Storage/RelationalConnection.cs
@@ -224,8 +224,8 @@ public virtual IDbContextTransaction BeginTransaction(System.Data.IsolationLevel
transactionId,
startTime);
- var dbTransaction = interceptionResult.HasValue
- ? interceptionResult.Value.Result
+ var dbTransaction = interceptionResult.HasResult
+ ? interceptionResult.Result
: DbConnection.BeginTransaction(isolationLevel);
dbTransaction = Dependencies.TransactionLogger.TransactionStarted(
@@ -266,8 +266,8 @@ public virtual async Task BeginTransactionAsync(
startTime,
cancellationToken);
- var dbTransaction = interceptionResult.HasValue
- ? interceptionResult.Value.Result
+ var dbTransaction = interceptionResult.HasResult
+ ? interceptionResult.Result
: await DbConnection.BeginTransactionAsync(isolationLevel, cancellationToken);
dbTransaction = await Dependencies.TransactionLogger.TransactionStartedAsync(
@@ -500,7 +500,7 @@ private void OpenDbConnection(bool errorsExpected)
try
{
- if (interceptionResult == null)
+ if (!interceptionResult.IsSuppressed)
{
DbConnection.Open();
}
@@ -530,7 +530,7 @@ var interceptionResult
try
{
- if (interceptionResult == null)
+ if (!interceptionResult.IsSuppressed)
{
await DbConnection.OpenAsync(cancellationToken);
}
@@ -629,7 +629,7 @@ public virtual bool Close()
try
{
- if (interceptionResult == null)
+ if (!interceptionResult.IsSuppressed)
{
DbConnection.Close();
}
@@ -682,7 +682,7 @@ public virtual async Task CloseAsync()
try
{
- if (interceptionResult == null)
+ if (!interceptionResult.IsSuppressed)
{
await DbConnection.CloseAsync();
}
diff --git a/src/EFCore.Relational/Storage/RelationalDataReader.cs b/src/EFCore.Relational/Storage/RelationalDataReader.cs
index b82a2511d83..7835a25fbf4 100644
--- a/src/EFCore.Relational/Storage/RelationalDataReader.cs
+++ b/src/EFCore.Relational/Storage/RelationalDataReader.cs
@@ -103,26 +103,29 @@ public virtual void Dispose()
{
if (!_disposed)
{
- InterceptionResult? interceptionResult = null;
+ var interceptionResult = default(InterceptionResult);
try
{
_reader.Close(); // can throw
- interceptionResult = _logger?.DataReaderDisposing(
- _connection,
- _command,
- _reader,
- _commandId,
- _reader.RecordsAffected,
- _readCount,
- _startTime,
- _stopwatch.Elapsed); // can throw
+ if (_logger != null)
+ {
+ interceptionResult = _logger.DataReaderDisposing(
+ _connection,
+ _command,
+ _reader,
+ _commandId,
+ _reader.RecordsAffected,
+ _readCount,
+ _startTime,
+ _stopwatch.Elapsed); // can throw
+ }
}
finally
{
_disposed = true;
- if (interceptionResult == null)
+ if (!interceptionResult.IsSuppressed)
{
_reader.Dispose();
_command.Parameters.Clear();
@@ -140,26 +143,29 @@ public virtual async ValueTask DisposeAsync()
{
if (!_disposed)
{
- InterceptionResult? interceptionResult = null;
+ var interceptionResult = default(InterceptionResult);
try
{
_reader.Close(); // can throw
- interceptionResult = _logger?.DataReaderDisposing(
- _connection,
- _command,
- _reader,
- _commandId,
- _reader.RecordsAffected,
- _readCount,
- _startTime,
- _stopwatch.Elapsed); // can throw
+ if (_logger != null)
+ {
+ interceptionResult = _logger.DataReaderDisposing(
+ _connection,
+ _command,
+ _reader,
+ _commandId,
+ _reader.RecordsAffected,
+ _readCount,
+ _startTime,
+ _stopwatch.Elapsed); // can throw
+ }
}
finally
{
_disposed = true;
- if (interceptionResult == null)
+ if (!interceptionResult.IsSuppressed)
{
await _reader.DisposeAsyncIfAvailable();
_command.Parameters.Clear();
diff --git a/src/EFCore.Relational/Storage/RelationalTransaction.cs b/src/EFCore.Relational/Storage/RelationalTransaction.cs
index b924def4b95..f9c31859daf 100644
--- a/src/EFCore.Relational/Storage/RelationalTransaction.cs
+++ b/src/EFCore.Relational/Storage/RelationalTransaction.cs
@@ -97,7 +97,7 @@ public virtual void Commit()
TransactionId,
startTime);
- if (interceptionResult == null)
+ if (!interceptionResult.IsSuppressed)
{
_dbTransaction.Commit();
}
@@ -142,7 +142,7 @@ public virtual void Rollback()
TransactionId,
startTime);
- if (interceptionResult == null)
+ if (!interceptionResult.IsSuppressed)
{
_dbTransaction.Rollback();
}
@@ -190,7 +190,7 @@ public virtual async Task CommitAsync(CancellationToken cancellationToken = defa
startTime,
cancellationToken);
- if (interceptionResult == null)
+ if (!interceptionResult.IsSuppressed)
{
await _dbTransaction.CommitAsync(cancellationToken);
}
@@ -240,7 +240,7 @@ public virtual async Task RollbackAsync(CancellationToken cancellationToken = de
startTime,
cancellationToken);
- if (interceptionResult == null)
+ if (!interceptionResult.IsSuppressed)
{
await _dbTransaction.RollbackAsync(cancellationToken);
}
diff --git a/src/EFCore/Diagnostics/InterceptionResult.cs b/src/EFCore/Diagnostics/InterceptionResult.cs
index c08e78508a9..025f7b343eb 100644
--- a/src/EFCore/Diagnostics/InterceptionResult.cs
+++ b/src/EFCore/Diagnostics/InterceptionResult.cs
@@ -12,11 +12,23 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics
/// A value of this type is passed to all interceptor methods that are called before the operation
/// being intercepted is executed.
/// Typically the interceptor should return the value passed in.
- /// However, returning some other non-null value will cause the operation being intercepted to
- /// be suppressed; that is, the operation is not executed.
+ /// However, creating a result with causes the operation being
+ /// intercepted to be suppressed; that is, the operation is not executed.
///
///
public readonly struct InterceptionResult
{
+ ///
+ /// Creates a new instance indicating that
+ /// execution should be suppressed.
+ ///
+ public static InterceptionResult Suppress() => new InterceptionResult(true);
+
+ private InterceptionResult(bool suppress) => IsSuppressed = suppress;
+
+ ///
+ /// If true, then interception is suppressed.
+ ///
+ public bool IsSuppressed { get; }
}
}
diff --git a/src/EFCore/Diagnostics/InterceptionResult`.cs b/src/EFCore/Diagnostics/InterceptionResult`.cs
index 7f6a195ea0e..3a62ffddcbe 100644
--- a/src/EFCore/Diagnostics/InterceptionResult`.cs
+++ b/src/EFCore/Diagnostics/InterceptionResult`.cs
@@ -1,39 +1,70 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using JetBrains.Annotations;
namespace Microsoft.EntityFrameworkCore.Diagnostics
{
///
///
- /// Represents a result from an such as an 'IDbCommandInterceptor' to allow
+ /// Represents a result from an such as an 'IDbCommandInterceptor' to allow
/// suppression of the normal operation being intercepted.
///
///
/// A value of this type is passed to all interceptor methods that are called before the operation
/// being intercepted is executed.
/// Typically the interceptor should return the value passed in.
- /// However, returning some other non-null value will cause the operation being intercepted to
- /// be suppressed; that is, the operation is not executed.
- /// The value is then used as a substitute return value for the operation that was suppressed.
+ /// However, creating a result with causes the operation being
+ /// intercepted to be suppressed; that is, the operation is not executed.
+ /// The value in the result is then used as a substitute return value for the operation that was suppressed.
///
///
/// The new result to use.
public readonly struct InterceptionResult
{
+ private readonly TResult _result;
+
///
- /// Creates a new instance.
+ /// Creates a new instance indicating that
+ /// execution should be suppressed and the given result should be used instead.
///
/// The result to use.
- public InterceptionResult([CanBeNull] TResult result)
+ public static InterceptionResult SuppressWithResult([CanBeNull] TResult result)
+ => new InterceptionResult(result);
+
+ private InterceptionResult(TResult result)
+ {
+ _result = result;
+ HasResult = true;
+ }
+
+ ///
+ ///
+ /// The result to use.
+ ///
+ ///
+ /// The property can only be accessed if is true. The concept here
+ /// is the same as and
+ ///
+ /// when is false.
+ ///
+ public TResult Result
{
- Result = result;
+ get
+ {
+ if (!HasResult)
+ {
+ throw new InvalidOperationException(CoreStrings.NoInterceptionResult);
+ }
+
+ return _result;
+ }
}
///
- /// The result.
+ /// If true, then interception is suppressed, and contains the result to use.
///
- public TResult Result { get; }
+ public bool HasResult { get; }
}
}
diff --git a/src/EFCore/Properties/CoreStrings.Designer.cs b/src/EFCore/Properties/CoreStrings.Designer.cs
index 52c1179dff9..e664e66bcb7 100644
--- a/src/EFCore/Properties/CoreStrings.Designer.cs
+++ b/src/EFCore/Properties/CoreStrings.Designer.cs
@@ -1,4 +1,4 @@
-//
+//
using System;
using System.Reflection;
@@ -2148,6 +2148,12 @@ public static string UnableToDiscriminate([CanBeNull] object entityType, [CanBeN
GetString("UnableToDiscriminate", nameof(entityType), nameof(discriminator)),
entityType, discriminator);
+ ///
+ /// 'InterceptionResult.Result' was called when 'InterceptionResult.HasResult' is false.
+ ///
+ public static string NoInterceptionResult
+ => GetString("NoInterceptionResult");
+
///
/// When performing a set operation, both operands must have the same Include operations.
///
diff --git a/src/EFCore/Properties/CoreStrings.resx b/src/EFCore/Properties/CoreStrings.resx
index 1e2ccbe89ab..a220de61cd5 100644
--- a/src/EFCore/Properties/CoreStrings.resx
+++ b/src/EFCore/Properties/CoreStrings.resx
@@ -1186,6 +1186,9 @@
Unable to materialize entity of type '{entityType}'. No discriminators matched '{discriminator}'.
+
+ 'InterceptionResult.Result' was called when 'InterceptionResult.HasResult' is false.
+
When performing a set operation, both operands must have the same Include operations.
diff --git a/test/EFCore.Relational.Specification.Tests/CommandInterceptionTestBase.cs b/test/EFCore.Relational.Specification.Tests/CommandInterceptionTestBase.cs
index 13cef76d4cb..3ba28b146f6 100644
--- a/test/EFCore.Relational.Specification.Tests/CommandInterceptionTestBase.cs
+++ b/test/EFCore.Relational.Specification.Tests/CommandInterceptionTestBase.cs
@@ -184,25 +184,25 @@ public SuppressingReaderCommandInterceptor()
{
}
- public override InterceptionResult? ReaderExecuting(
+ public override InterceptionResult ReaderExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
base.ReaderExecuting(command, eventData, result);
- return new InterceptionResult(new FakeDbDataReader());
+ return InterceptionResult.SuppressWithResult(new FakeDbDataReader());
}
- public override Task?> ReaderExecutingAsync(
+ public override Task> ReaderExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
base.ReaderExecutingAsync(command, eventData, result, cancellationToken);
- return Task.FromResult?>(new InterceptionResult(new FakeDbDataReader()));
+ return Task.FromResult(InterceptionResult.SuppressWithResult(new FakeDbDataReader()));
}
}
@@ -250,26 +250,26 @@ public SuppressingScalarCommandInterceptor()
public const string InterceptedResult = "Bet you weren't expecting a string!";
- public override InterceptionResult? ScalarExecuting(
+ public override InterceptionResult ScalarExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
base.ScalarExecuting(command, eventData, result);
- return new InterceptionResult(InterceptedResult);
+ return InterceptionResult.SuppressWithResult(InterceptedResult);
}
- public override Task?> ScalarExecutingAsync(
+ public override Task> ScalarExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
base.ScalarExecutingAsync(command, eventData, result, cancellationToken);
- return Task.FromResult?>(
- new InterceptionResult(InterceptedResult));
+ return Task.FromResult(
+ InterceptionResult.SuppressWithResult(InterceptedResult));
}
}
@@ -312,25 +312,25 @@ public SuppressingNonQueryCommandInterceptor()
{
}
- public override InterceptionResult? NonQueryExecuting(
+ public override InterceptionResult NonQueryExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
base.NonQueryExecuting(command, eventData, result);
- return new InterceptionResult(2);
+ return InterceptionResult.SuppressWithResult(2);
}
- public override Task?> NonQueryExecutingAsync(
+ public override Task> NonQueryExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
base.NonQueryExecutingAsync(command, eventData, result, cancellationToken);
- return Task.FromResult?>(new InterceptionResult(2));
+ return Task.FromResult(InterceptionResult.SuppressWithResult(2));
}
}
@@ -372,20 +372,20 @@ public MutatingReaderCommandInterceptor()
{
}
- public override InterceptionResult? ReaderExecuting(
+ public override InterceptionResult ReaderExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
MutateQuery(command);
return base.ReaderExecuting(command, eventData, result);
}
- public override Task?> ReaderExecutingAsync(
+ public override Task> ReaderExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
MutateQuery(command);
@@ -441,20 +441,20 @@ public MutatingScalarCommandInterceptor()
public const string MutatedSql = "SELECT 2";
- public override InterceptionResult? ScalarExecuting(
+ public override InterceptionResult ScalarExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
command.CommandText = MutatedSql;
return base.ScalarExecuting(command, eventData, result);
}
- public override Task?> ScalarExecutingAsync(
+ public override Task> ScalarExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
command.CommandText = MutatedSql;
@@ -504,20 +504,20 @@ public MutatingNonQueryCommandInterceptor()
{
}
- public override InterceptionResult? NonQueryExecuting(
+ public override InterceptionResult NonQueryExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
command.CommandText = MutatedSql;
return base.NonQueryExecuting(command, eventData, result);
}
- public override Task?> NonQueryExecutingAsync(
+ public override Task> NonQueryExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
command.CommandText = MutatedSql;
@@ -564,27 +564,28 @@ public QueryReplacingReaderCommandInterceptor()
{
}
- public override InterceptionResult? ReaderExecuting(
+ public override InterceptionResult ReaderExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
base.ReaderExecuting(command, eventData, result);
// Note: this DbCommand will not get disposed...can be problematic on some providers
- return new InterceptionResult(CreateNewCommand(command).ExecuteReader());
+ return InterceptionResult.SuppressWithResult(CreateNewCommand(command).ExecuteReader());
}
- public override async Task?> ReaderExecutingAsync(
+ public override async Task> ReaderExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
await base.ReaderExecutingAsync(command, eventData, result, cancellationToken);
// Note: this DbCommand will not get disposed...can be problematic on some providers
- return new InterceptionResult(await CreateNewCommand(command).ExecuteReaderAsync(cancellationToken));
+ return InterceptionResult.SuppressWithResult(
+ await CreateNewCommand(command).ExecuteReaderAsync(cancellationToken));
}
private static DbCommand CreateNewCommand(DbCommand command)
@@ -638,27 +639,27 @@ public QueryReplacingScalarCommandInterceptor()
{
}
- public override InterceptionResult? ScalarExecuting(
+ public override InterceptionResult ScalarExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
base.ScalarExecuting(command, eventData, result);
// Note: this DbCommand will not get disposed...can be problematic on some providers
- return new InterceptionResult(CreateNewCommand(command).ExecuteScalar());
+ return InterceptionResult.SuppressWithResult(CreateNewCommand(command).ExecuteScalar());
}
- public override async Task?> ScalarExecutingAsync(
+ public override async Task> ScalarExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
await base.ScalarExecutingAsync(command, eventData, result, cancellationToken);
// Note: this DbCommand will not get disposed...can be problematic on some providers
- return new InterceptionResult(await CreateNewCommand(command).ExecuteScalarAsync(cancellationToken));
+ return InterceptionResult.SuppressWithResult(await CreateNewCommand(command).ExecuteScalarAsync(cancellationToken));
}
private static DbCommand CreateNewCommand(DbCommand command)
@@ -709,27 +710,27 @@ public QueryReplacingNonQueryCommandInterceptor()
{
}
- public override InterceptionResult? NonQueryExecuting(
+ public override InterceptionResult NonQueryExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
base.NonQueryExecuting(command, eventData, result);
// Note: this DbCommand will not get disposed...can be problematic on some providers
- return new InterceptionResult(CreateNewCommand(command).ExecuteNonQuery());
+ return InterceptionResult.SuppressWithResult(CreateNewCommand(command).ExecuteNonQuery());
}
- public override async Task?> NonQueryExecutingAsync(
+ public override async Task> NonQueryExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
await base.NonQueryExecutingAsync(command, eventData, result, cancellationToken);
// Note: this DbCommand will not get disposed...can be problematic on some providers
- return new InterceptionResult(await CreateNewCommand(command).ExecuteNonQueryAsync(cancellationToken));
+ return InterceptionResult.SuppressWithResult(await CreateNewCommand(command).ExecuteNonQueryAsync(cancellationToken));
}
private DbCommand CreateNewCommand(DbCommand command)
@@ -1149,52 +1150,52 @@ public virtual async Task Intercept_non_query_to_throw(bool async, bool inject)
protected class ThrowingReaderCommandInterceptor : DbCommandInterceptor
{
- public override InterceptionResult? ReaderExecuting(
+ public override InterceptionResult ReaderExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
throw new Exception("Bang!");
}
- public override Task?> ReaderExecutingAsync(
+ public override Task> ReaderExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
throw new Exception("Bang!");
}
- public override InterceptionResult? ScalarExecuting(
+ public override InterceptionResult ScalarExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
throw new Exception("Bang!");
}
- public override Task?> ScalarExecutingAsync(
+ public override Task> ScalarExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
throw new Exception("Bang!");
}
- public override InterceptionResult? NonQueryExecuting(
+ public override InterceptionResult NonQueryExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
throw new Exception("Bang!");
}
- public override Task?> NonQueryExecutingAsync(
+ public override Task> NonQueryExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
throw new Exception("Bang!");
@@ -1497,10 +1498,10 @@ protected CommandInterceptorBase(DbCommandMethod commandMethod)
public bool ExecutedCalled { get; set; }
public bool FailedCalled { get; set; }
- public virtual InterceptionResult? ReaderExecuting(
+ public virtual InterceptionResult ReaderExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
Assert.False(eventData.IsAsync);
SyncCalled = true;
@@ -1509,10 +1510,10 @@ protected CommandInterceptorBase(DbCommandMethod commandMethod)
return result;
}
- public virtual InterceptionResult? ScalarExecuting(
+ public virtual InterceptionResult ScalarExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
Assert.False(eventData.IsAsync);
SyncCalled = true;
@@ -1521,10 +1522,10 @@ protected CommandInterceptorBase(DbCommandMethod commandMethod)
return result;
}
- public virtual InterceptionResult? NonQueryExecuting(
+ public virtual InterceptionResult NonQueryExecuting(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
Assert.False(eventData.IsAsync);
SyncCalled = true;
@@ -1533,10 +1534,10 @@ protected CommandInterceptorBase(DbCommandMethod commandMethod)
return result;
}
- public virtual Task?> ReaderExecutingAsync(
+ public virtual Task> ReaderExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
Assert.True(eventData.IsAsync);
@@ -1546,10 +1547,10 @@ protected CommandInterceptorBase(DbCommandMethod commandMethod)
return Task.FromResult(result);
}
- public virtual Task?> ScalarExecutingAsync(
+ public virtual Task> ScalarExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
Assert.True(eventData.IsAsync);
@@ -1559,10 +1560,10 @@ protected CommandInterceptorBase(DbCommandMethod commandMethod)
return Task.FromResult(result);
}
- public virtual Task?> NonQueryExecutingAsync(
+ public virtual Task> NonQueryExecutingAsync(
DbCommand command,
CommandEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
Assert.True(eventData.IsAsync);
@@ -1668,10 +1669,10 @@ public Task CommandFailedAsync(
return Task.CompletedTask;
}
- public InterceptionResult? DataReaderDisposing(
+ public InterceptionResult DataReaderDisposing(
DbCommand command,
DataReaderDisposingEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
Assert.NotNull(eventData.DataReader);
Assert.Same(Context, eventData.Context);
diff --git a/test/EFCore.Relational.Specification.Tests/ConnectionInterceptionTestBase.cs b/test/EFCore.Relational.Specification.Tests/ConnectionInterceptionTestBase.cs
index 88a32500952..231a72291bc 100644
--- a/test/EFCore.Relational.Specification.Tests/ConnectionInterceptionTestBase.cs
+++ b/test/EFCore.Relational.Specification.Tests/ConnectionInterceptionTestBase.cs
@@ -241,35 +241,35 @@ protected class NoOpConnectionInterceptor : DbConnectionInterceptor
protected class ConnectionOverridingInterceptor : ConnectionInterceptor
{
- public override InterceptionResult? ConnectionOpening(
+ public override InterceptionResult ConnectionOpening(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
base.ConnectionOpening(connection, eventData, result);
- if (result == null)
+ if (!result.IsSuppressed)
{
connection.Open();
}
- return new InterceptionResult();
+ return InterceptionResult.Suppress();
}
- public override async Task ConnectionOpeningAsync(
+ public override async Task ConnectionOpeningAsync(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
await base.ConnectionOpeningAsync(connection, eventData, result, cancellationToken);
- if (result == null)
+ if (!result.IsSuppressed)
{
await connection.OpenAsync(cancellationToken);
}
- return new InterceptionResult();
+ return InterceptionResult.Suppress();
}
}
@@ -302,10 +302,10 @@ public void Reset()
FailedCalled = false;
}
- public virtual InterceptionResult? ConnectionOpening(
+ public virtual InterceptionResult ConnectionOpening(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
Assert.False(eventData.IsAsync);
SyncCalled = true;
@@ -314,10 +314,10 @@ public void Reset()
return result;
}
- public virtual Task ConnectionOpeningAsync(
+ public virtual Task ConnectionOpeningAsync(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result,
+ InterceptionResult result,
CancellationToken cancellationToken = default)
{
Assert.True(eventData.IsAsync);
@@ -348,10 +348,10 @@ public virtual Task ConnectionOpenedAsync(
return Task.CompletedTask;
}
- public virtual InterceptionResult? ConnectionClosing(
+ public virtual InterceptionResult ConnectionClosing(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
Assert.False(eventData.IsAsync);
SyncCalled = true;
@@ -360,10 +360,10 @@ public virtual Task ConnectionOpenedAsync(
return result;
}
- public virtual Task ConnectionClosingAsync(
+ public virtual Task ConnectionClosingAsync(
DbConnection connection,
ConnectionEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
Assert.True(eventData.IsAsync);
AsyncCalled = true;
diff --git a/test/EFCore.Relational.Specification.Tests/TransactionInterceptionTestBase.cs b/test/EFCore.Relational.Specification.Tests/TransactionInterceptionTestBase.cs
index 199b6df0506..15e6b9039b8 100644
--- a/test/EFCore.Relational.Specification.Tests/TransactionInterceptionTestBase.cs
+++ b/test/EFCore.Relational.Specification.Tests/TransactionInterceptionTestBase.cs
@@ -140,25 +140,25 @@ public virtual async Task Intercept_BeginTransaction_to_suppress(bool async)
protected class SuppressingTransactionInterceptor : TransactionInterceptor
{
- public override InterceptionResult? TransactionStarting(
+ public override InterceptionResult TransactionStarting(
DbConnection connection,
TransactionStartingEventData eventData,
- InterceptionResult? result)
+ InterceptionResult result)
{
base.TransactionStarting(connection, eventData, result);
- return new InterceptionResult(new FakeDbTransaction(connection, eventData.IsolationLevel));
+ return InterceptionResult.SuppressWithResult(new FakeDbTransaction(connection, eventData.IsolationLevel));
}
- public override async Task?> TransactionStartingAsync(
+ public override async Task