CommitFailureHandler CommitFailureHandler CommitFailureHandler Class

Definition

A transaction handler that allows to gracefully recover from connection failures during transaction commit by storing transaction tracing information in the database. It needs to be registered by using SetDefaultTransactionHandler(Func<TransactionHandler>).

public class CommitFailureHandler : System.Data.Entity.Infrastructure.TransactionHandler
type CommitFailureHandler = class
    inherit TransactionHandler
Public Class CommitFailureHandler
Inherits TransactionHandler
Inheritance
CommitFailureHandlerCommitFailureHandlerCommitFailureHandler

Remarks

This transaction handler uses TransactionContext to store the transaction information the schema used can be configured by creating a class derived from TransactionContext that overrides OnModelCreating(DbModelBuilder) and passing it to the constructor of this class.

Constructors

CommitFailureHandler() CommitFailureHandler() CommitFailureHandler()

Initializes a new instance of the CommitFailureHandler class using the default TransactionContext.

CommitFailureHandler(Func<DbConnection,TransactionContext>) CommitFailureHandler(Func<DbConnection,TransactionContext>) CommitFailureHandler(Func<DbConnection,TransactionContext>)

Initializes a new instance of the CommitFailureHandler class.

Properties

Connection Connection Connection

Gets the connection.

(Inherited from TransactionHandler)
DbContext DbContext DbContext

Gets the context.

(Inherited from TransactionHandler)
IsDisposed IsDisposed IsDisposed

Gets or sets a value indicating whether this transaction handler is disposed.

(Inherited from TransactionHandler)
ObjectContext ObjectContext ObjectContext

Gets the context.

(Inherited from TransactionHandler)
PruningLimit PruningLimit PruningLimit

Gets the number of transactions to be executed on the context before the transaction log will be cleaned. The default value is 20.

TransactionContext TransactionContext TransactionContext

Gets the transaction context.

Transactions Transactions Transactions

The map between the store transactions and the transaction tracking objects

Methods

BeganTransaction(DbConnection, BeginTransactionInterceptionContext) BeganTransaction(DbConnection, BeginTransactionInterceptionContext) BeganTransaction(DbConnection, BeginTransactionInterceptionContext)

Stores the tracking information for the new transaction to the database in the same transaction.

BeginningTransaction(DbConnection, BeginTransactionInterceptionContext) BeginningTransaction(DbConnection, BeginTransactionInterceptionContext) BeginningTransaction(DbConnection, BeginTransactionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
BuildDatabaseInitializationScript() BuildDatabaseInitializationScript() BuildDatabaseInitializationScript()
ClearTransactionHistory() ClearTransactionHistory() ClearTransactionHistory()

Removes all the transaction history.

ClearTransactionHistoryAsync() ClearTransactionHistoryAsync() ClearTransactionHistoryAsync()

Asynchronously removes all the transaction history.

ClearTransactionHistoryAsync(CancellationToken) ClearTransactionHistoryAsync(CancellationToken) ClearTransactionHistoryAsync(CancellationToken)

Asynchronously removes all the transaction history.

Closed(DbConnection, DbConnectionInterceptionContext) Closed(DbConnection, DbConnectionInterceptionContext) Closed(DbConnection, DbConnectionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
Closing(DbConnection, DbConnectionInterceptionContext) Closing(DbConnection, DbConnectionInterceptionContext) Closing(DbConnection, DbConnectionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
Committed(DbTransaction, DbTransactionInterceptionContext) Committed(DbTransaction, DbTransactionInterceptionContext) Committed(DbTransaction, DbTransactionInterceptionContext)

If there was an exception thrown checks the database for this transaction and rethrows it if not found. Otherwise marks the commit as succeeded and queues the transaction information to be deleted.

Committing(DbTransaction, DbTransactionInterceptionContext) Committing(DbTransaction, DbTransactionInterceptionContext) Committing(DbTransaction, DbTransactionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
ConnectionGetting(DbTransaction, DbTransactionInterceptionContext<DbConnection>) ConnectionGetting(DbTransaction, DbTransactionInterceptionContext<DbConnection>) ConnectionGetting(DbTransaction, DbTransactionInterceptionContext<DbConnection>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
ConnectionGot(DbTransaction, DbTransactionInterceptionContext<DbConnection>) ConnectionGot(DbTransaction, DbTransactionInterceptionContext<DbConnection>) ConnectionGot(DbTransaction, DbTransactionInterceptionContext<DbConnection>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
ConnectionStringGetting(DbConnection, DbConnectionInterceptionContext<String>) ConnectionStringGetting(DbConnection, DbConnectionInterceptionContext<String>) ConnectionStringGetting(DbConnection, DbConnectionInterceptionContext<String>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
ConnectionStringGot(DbConnection, DbConnectionInterceptionContext<String>) ConnectionStringGot(DbConnection, DbConnectionInterceptionContext<String>) ConnectionStringGot(DbConnection, DbConnectionInterceptionContext<String>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
ConnectionStringSet(DbConnection, DbConnectionPropertyInterceptionContext<String>) ConnectionStringSet(DbConnection, DbConnectionPropertyInterceptionContext<String>) ConnectionStringSet(DbConnection, DbConnectionPropertyInterceptionContext<String>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
ConnectionStringSetting(DbConnection, DbConnectionPropertyInterceptionContext<String>) ConnectionStringSetting(DbConnection, DbConnectionPropertyInterceptionContext<String>) ConnectionStringSetting(DbConnection, DbConnectionPropertyInterceptionContext<String>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
ConnectionTimeoutGetting(DbConnection, DbConnectionInterceptionContext<Int32>) ConnectionTimeoutGetting(DbConnection, DbConnectionInterceptionContext<Int32>) ConnectionTimeoutGetting(DbConnection, DbConnectionInterceptionContext<Int32>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
ConnectionTimeoutGot(DbConnection, DbConnectionInterceptionContext<Int32>) ConnectionTimeoutGot(DbConnection, DbConnectionInterceptionContext<Int32>) ConnectionTimeoutGot(DbConnection, DbConnectionInterceptionContext<Int32>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
DatabaseGetting(DbConnection, DbConnectionInterceptionContext<String>) DatabaseGetting(DbConnection, DbConnectionInterceptionContext<String>) DatabaseGetting(DbConnection, DbConnectionInterceptionContext<String>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
DatabaseGot(DbConnection, DbConnectionInterceptionContext<String>) DatabaseGot(DbConnection, DbConnectionInterceptionContext<String>) DatabaseGot(DbConnection, DbConnectionInterceptionContext<String>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
DataSourceGetting(DbConnection, DbConnectionInterceptionContext<String>) DataSourceGetting(DbConnection, DbConnectionInterceptionContext<String>) DataSourceGetting(DbConnection, DbConnectionInterceptionContext<String>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
DataSourceGot(DbConnection, DbConnectionInterceptionContext<String>) DataSourceGot(DbConnection, DbConnectionInterceptionContext<String>) DataSourceGot(DbConnection, DbConnectionInterceptionContext<String>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
Dispose() Dispose() Dispose() Inherited from TransactionHandler
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)
Disposed(DbConnection, DbConnectionInterceptionContext) Disposed(DbConnection, DbConnectionInterceptionContext) Disposed(DbConnection, DbConnectionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
Disposed(DbTransaction, DbTransactionInterceptionContext) Disposed(DbTransaction, DbTransactionInterceptionContext) Disposed(DbTransaction, DbTransactionInterceptionContext)

Stops tracking the transaction that was disposed.

Disposing(DbConnection, DbConnectionInterceptionContext) Disposing(DbConnection, DbConnectionInterceptionContext) Disposing(DbConnection, DbConnectionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
Disposing(DbTransaction, DbTransactionInterceptionContext) Disposing(DbTransaction, DbTransactionInterceptionContext) Disposing(DbTransaction, DbTransactionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
EnlistedTransaction(DbConnection, EnlistTransactionInterceptionContext) EnlistedTransaction(DbConnection, EnlistTransactionInterceptionContext) EnlistedTransaction(DbConnection, EnlistTransactionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
EnlistingTransaction(DbConnection, EnlistTransactionInterceptionContext) EnlistingTransaction(DbConnection, EnlistTransactionInterceptionContext) EnlistingTransaction(DbConnection, EnlistTransactionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
FromContext(DbContext) FromContext(DbContext) FromContext(DbContext)

Gets the CommitFailureHandler associated with the context if there is one; otherwise returns null.

FromContext(ObjectContext) FromContext(ObjectContext) FromContext(ObjectContext)

Gets the CommitFailureHandler associated with the context if there is one; otherwise returns null.

GetExecutionStrategy() GetExecutionStrategy() GetExecutionStrategy()

Creates a new instance of an IDbExecutionStrategy to use for quering the transaction log. If null the default will be used.

Initialize(DbContext, DbConnection) Initialize(DbContext, DbConnection) Initialize(DbContext, DbConnection)
Initialize(ObjectContext) Initialize(ObjectContext) Initialize(ObjectContext)
IsolationLevelGetting(DbTransaction, DbTransactionInterceptionContext<IsolationLevel>) IsolationLevelGetting(DbTransaction, DbTransactionInterceptionContext<IsolationLevel>) IsolationLevelGetting(DbTransaction, DbTransactionInterceptionContext<IsolationLevel>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
IsolationLevelGot(DbTransaction, DbTransactionInterceptionContext<IsolationLevel>) IsolationLevelGot(DbTransaction, DbTransactionInterceptionContext<IsolationLevel>) IsolationLevelGot(DbTransaction, DbTransactionInterceptionContext<IsolationLevel>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
MarkTransactionForPruning(TransactionRow) MarkTransactionForPruning(TransactionRow) MarkTransactionForPruning(TransactionRow)

Adds the specified transaction to the list of transactions that can be removed from the database

MatchesParentContext(DbConnection, DbInterceptionContext) MatchesParentContext(DbConnection, DbInterceptionContext) MatchesParentContext(DbConnection, DbInterceptionContext)

Checks whether the supplied interception context contains the target context or the supplied connection is the same as the one used by the target context.

(Inherited from TransactionHandler)
Opened(DbConnection, DbConnectionInterceptionContext) Opened(DbConnection, DbConnectionInterceptionContext) Opened(DbConnection, DbConnectionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
Opening(DbConnection, DbConnectionInterceptionContext) Opening(DbConnection, DbConnectionInterceptionContext) Opening(DbConnection, DbConnectionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
PruneTransactionHistory() PruneTransactionHistory() PruneTransactionHistory()

Removes the transactions marked for deletion.

PruneTransactionHistory(Boolean, Boolean) PruneTransactionHistory(Boolean, Boolean) PruneTransactionHistory(Boolean, Boolean)

Removes the transactions marked for deletion if their number exceeds PruningLimit.

PruneTransactionHistoryAsync() PruneTransactionHistoryAsync() PruneTransactionHistoryAsync()

Asynchronously removes the transactions marked for deletion.

PruneTransactionHistoryAsync(Boolean, Boolean, CancellationToken) PruneTransactionHistoryAsync(Boolean, Boolean, CancellationToken) PruneTransactionHistoryAsync(Boolean, Boolean, CancellationToken)

Removes the transactions marked for deletion if their number exceeds PruningLimit.

PruneTransactionHistoryAsync(CancellationToken) PruneTransactionHistoryAsync(CancellationToken) PruneTransactionHistoryAsync(CancellationToken)

Asynchronously removes the transactions marked for deletion.

RolledBack(DbTransaction, DbTransactionInterceptionContext) RolledBack(DbTransaction, DbTransactionInterceptionContext) RolledBack(DbTransaction, DbTransactionInterceptionContext)

Stops tracking the transaction that was rolled back.

RollingBack(DbTransaction, DbTransactionInterceptionContext) RollingBack(DbTransaction, DbTransactionInterceptionContext) RollingBack(DbTransaction, DbTransactionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
ServerVersionGetting(DbConnection, DbConnectionInterceptionContext<String>) ServerVersionGetting(DbConnection, DbConnectionInterceptionContext<String>) ServerVersionGetting(DbConnection, DbConnectionInterceptionContext<String>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
ServerVersionGot(DbConnection, DbConnectionInterceptionContext<String>) ServerVersionGot(DbConnection, DbConnectionInterceptionContext<String>) ServerVersionGot(DbConnection, DbConnectionInterceptionContext<String>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
StateGetting(DbConnection, DbConnectionInterceptionContext<ConnectionState>) StateGetting(DbConnection, DbConnectionInterceptionContext<ConnectionState>) StateGetting(DbConnection, DbConnectionInterceptionContext<ConnectionState>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
StateGot(DbConnection, DbConnectionInterceptionContext<ConnectionState>) StateGot(DbConnection, DbConnectionInterceptionContext<ConnectionState>) StateGot(DbConnection, DbConnectionInterceptionContext<ConnectionState>)

Can be implemented in a derived class.

(Inherited from TransactionHandler)

Applies to