Example #1
0
 /// <summary>
 ///     Called at the start of <see cref="O:DbContext.SaveChangesAsync" />.
 /// </summary>
 /// <param name="eventData">Contextual information about the <see cref="DbContext" /> being used.</param>
 /// <param name="result">
 ///     Represents the current result if one exists.
 ///     This value will have <see cref="InterceptionResult{Int32}.HasResult" /> set to <see langword="true" /> if some previous
 ///     interceptor suppressed execution by calling <see cref="InterceptionResult{Int32}.SuppressWithResult" />.
 ///     This value is typically used as the return value for the implementation of this method.
 /// </param>
 /// <param name="cancellationToken">A <see cref="CancellationToken" /> to observe while waiting for the task to complete.</param>
 /// <returns>
 ///     If <see cref="InterceptionResult{Int32}.HasResult" /> is false, the EF will continue as normal.
 ///     If <see cref="InterceptionResult{Int32}.HasResult" /> is true, then EF will suppress the operation it
 ///     was about to perform and use <see cref="InterceptionResult{Int32}.Result" /> instead.
 ///     A normal implementation of this method for any interceptor that is not attempting to change the result
 ///     is to return the <paramref name="result" /> value passed in.
 /// </returns>
 /// <exception cref="OperationCanceledException">If the <see cref="CancellationToken" /> is canceled.</exception>
 public virtual ValueTask <InterceptionResult <int> > SavingChangesAsync(
     DbContextEventData eventData,
     InterceptionResult <int> result,
     CancellationToken cancellationToken = default)
 => new(result);
Example #2
0
 /// <summary>
 ///     Called at the start of <see cref="O:DbContext.SaveChanges" />.
 /// </summary>
 /// <param name="eventData">Contextual information about the <see cref="DbContext" /> being used.</param>
 /// <param name="result">
 ///     Represents the current result if one exists.
 ///     This value will have <see cref="InterceptionResult{Int32}.HasResult" /> set to <see langword="true" /> if some previous
 ///     interceptor suppressed execution by calling <see cref="InterceptionResult{Int32}.SuppressWithResult" />.
 ///     This value is typically used as the return value for the implementation of this method.
 /// </param>
 /// <returns>
 ///     If <see cref="InterceptionResult{Int32}.HasResult" /> is false, the EF will continue as normal.
 ///     If <see cref="InterceptionResult{Int32}.HasResult" /> is true, then EF will suppress the operation it
 ///     was about to perform and use <see cref="InterceptionResult{Int32}.Result" /> instead.
 ///     A normal implementation of this method for any interceptor that is not attempting to change the result
 ///     is to return the <paramref name="result" /> value passed in.
 /// </returns>
 public virtual InterceptionResult <int> SavingChanges(DbContextEventData eventData, InterceptionResult <int> result)
 => result;