IDbTransactionInterceptor.TransactionStartedAsync 方法

定义

public System.Threading.Tasks.Task<System.Data.Common.DbTransaction> TransactionStartedAsync (System.Data.Common.DbConnection connection, Microsoft.EntityFrameworkCore.Diagnostics.TransactionEndEventData eventData, System.Data.Common.DbTransaction result, System.Threading.CancellationToken cancellationToken = default);
public System.Threading.Tasks.ValueTask<System.Data.Common.DbTransaction> TransactionStartedAsync (System.Data.Common.DbConnection connection, Microsoft.EntityFrameworkCore.Diagnostics.TransactionEndEventData eventData, System.Data.Common.DbTransaction result, System.Threading.CancellationToken cancellationToken = default);
public virtual System.Threading.Tasks.ValueTask<System.Data.Common.DbTransaction> TransactionStartedAsync (System.Data.Common.DbConnection connection, Microsoft.EntityFrameworkCore.Diagnostics.TransactionEndEventData eventData, System.Data.Common.DbTransaction result, System.Threading.CancellationToken cancellationToken = default);
abstract member TransactionStartedAsync : System.Data.Common.DbConnection * Microsoft.EntityFrameworkCore.Diagnostics.TransactionEndEventData * System.Data.Common.DbTransaction * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Data.Common.DbTransaction>
abstract member TransactionStartedAsync : System.Data.Common.DbConnection * Microsoft.EntityFrameworkCore.Diagnostics.TransactionEndEventData * System.Data.Common.DbTransaction * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Data.Common.DbTransaction>
abstract member TransactionStartedAsync : System.Data.Common.DbConnection * Microsoft.EntityFrameworkCore.Diagnostics.TransactionEndEventData * System.Data.Common.DbTransaction * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Data.Common.DbTransaction>
override this.TransactionStartedAsync : System.Data.Common.DbConnection * Microsoft.EntityFrameworkCore.Diagnostics.TransactionEndEventData * System.Data.Common.DbTransaction * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Data.Common.DbTransaction>
Public Function TransactionStartedAsync (connection As DbConnection, eventData As TransactionEndEventData, result As DbTransaction, Optional cancellationToken As CancellationToken = Nothing) As Task(Of DbTransaction)
Public Function TransactionStartedAsync (connection As DbConnection, eventData As TransactionEndEventData, result As DbTransaction, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of DbTransaction)
Public Overridable Function TransactionStartedAsync (connection As DbConnection, eventData As TransactionEndEventData, result As DbTransaction, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of DbTransaction)

参数

connection
DbConnection

连接。

eventData
TransactionEndEventData

有关连接和事务的上下文信息。

result
DbTransaction

调用 BeginTransactionAsync(IsolationLevel, CancellationToken)的结果。 此值通常用作此方法实现的返回值。

cancellationToken
CancellationToken

等待 CancellationToken 任务完成时要观察的 。

返回

提供 Task EF 将使用的结果的 。 对于未尝试更改结果的任何侦听器,此方法的实现是返回 result 传入的值,通常使用 FromResult<TResult>(TResult)

例外

注解

如果侦听器在 中 TransactionStarting(DbConnection, TransactionStartingEventData, InterceptionResult<DbTransaction>)禁止创建,则仍会调用此方法。 在本例中, result 是 返回 TransactionStarting(DbConnection, TransactionStartingEventData, InterceptionResult<DbTransaction>)的结果。

适用于