共用方式為


IDbTransactionInterceptor.TransactionStartedAsync 方法

定義

在 EF 呼叫 之後立即呼叫 BeginTransactionAsync(IsolationLevel, CancellationToken)

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>) 傳回的結果。

適用於