-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interceptor for DbUpdateConcurrencyException
Part of #626 Part of #16260 Allows #10443 functionally, although not optimally Relational version allows access to the connection, command, and reader from an async context, such that database commands could be used in the interceptor.
- Loading branch information
1 parent
62fb246
commit 6b1fb61
Showing
32 changed files
with
828 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/EFCore.Relational/Diagnostics/RelationalConcurrencyExceptionEventData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Diagnostics; | ||
|
||
/// <summary> | ||
/// A <see cref="DiagnosticSource" /> event payload used when a <see cref="DbUpdateConcurrencyException" /> is being thrown | ||
/// from a relational database provider. | ||
/// </summary> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-diagnostics">Logging, events, and diagnostics</see> for more information and examples. | ||
/// </remarks> | ||
public class RelationalConcurrencyExceptionEventData : ConcurrencyExceptionEventData | ||
{ | ||
/// <summary> | ||
/// Constructs the event payload. | ||
/// </summary> | ||
/// <param name="eventDefinition">The event definition.</param> | ||
/// <param name="messageGenerator">A delegate that generates a log message for this event.</param> | ||
/// <param name="context">The current <see cref="DbContext" />.</param> | ||
/// <param name="connection">The <see cref="DbConnection" /> being used.</param> | ||
/// <param name="command">The <see cref="DbCommand" /> being used.</param> | ||
/// <param name="dataReader">The <see cref="DbDataReader" /> being used.</param> | ||
/// <param name="commandId">A correlation ID that identifies the <see cref="DbCommand" /> instance being used.</param> | ||
/// <param name="connectionId">A correlation ID that identifies the <see cref="DbConnection" /> instance being used.</param> | ||
/// <param name="entries">The entries that were involved in the concurrency violation.</param> | ||
/// <param name="exception">The exception that will be thrown, unless throwing is suppressed.</param> | ||
public RelationalConcurrencyExceptionEventData( | ||
EventDefinitionBase eventDefinition, | ||
Func<EventDefinitionBase, EventData, string> messageGenerator, | ||
DbContext context, | ||
DbConnection connection, | ||
DbCommand command, | ||
DbDataReader dataReader, | ||
Guid commandId, | ||
Guid connectionId, | ||
IReadOnlyList<IUpdateEntry> entries, | ||
Exception exception) | ||
: base(eventDefinition, messageGenerator, context, entries, exception) | ||
{ | ||
Connection = connection; | ||
Command = command; | ||
DataReader = dataReader; | ||
CommandId = commandId; | ||
ConnectionId = connectionId; | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="DbConnection" /> being used. | ||
/// </summary> | ||
public virtual DbConnection Connection { get; } | ||
|
||
/// <summary> | ||
/// The <see cref="DbCommand" /> being used. | ||
/// </summary> | ||
public virtual DbCommand Command { get; } | ||
|
||
/// <summary> | ||
/// The <see cref="DbDataReader" /> being used. | ||
/// </summary> | ||
public virtual DbDataReader DataReader { get; } | ||
|
||
/// <summary> | ||
/// A correlation ID that identifies the <see cref="DbCommand" /> instance being used. | ||
/// </summary> | ||
public virtual Guid CommandId { get; } | ||
|
||
/// <summary> | ||
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used. | ||
/// </summary> | ||
public virtual Guid ConnectionId { get; } | ||
} |
Oops, something went wrong.