Share via


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
CommitFailureHandler

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()

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

CommitFailureHandler(Func<DbConnection,TransactionContext>)

Initializes a new instance of the CommitFailureHandler class.

Properties

Connection

Gets the connection.

(Inherited from TransactionHandler)
DbContext

Gets the context.

(Inherited from TransactionHandler)
IsDisposed

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

(Inherited from TransactionHandler)
ObjectContext

Gets the context.

(Inherited from TransactionHandler)
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

Gets the transaction context.

Transactions

The map between the store transactions and the transaction tracking objects

Methods

BeganTransaction(DbConnection, BeginTransactionInterceptionContext)

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

BeginningTransaction(DbConnection, BeginTransactionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
BuildDatabaseInitializationScript()

When implemented in a derived class returns the script to prepare the database for this transaction handler.

ClearTransactionHistory()

Removes all the transaction history.

ClearTransactionHistoryAsync()

Asynchronously removes all the transaction history.

ClearTransactionHistoryAsync(CancellationToken)

Asynchronously removes all the transaction history.

Closed(DbConnection, DbConnectionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
Closing(DbConnection, DbConnectionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
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)

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

(Inherited from TransactionHandler)
Dispose() (Inherited from TransactionHandler)
Dispose(Boolean)

Releases the resources used by this transaction handler.

Disposed(DbConnection, DbConnectionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
Disposed(DbTransaction, DbTransactionInterceptionContext)

Stops tracking the transaction that was disposed.

Disposing(DbConnection, DbConnectionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
Disposing(DbTransaction, DbTransactionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
EnlistedTransaction(DbConnection, EnlistTransactionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
EnlistingTransaction(DbConnection, EnlistTransactionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
FromContext(DbContext)

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

FromContext(ObjectContext)

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

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)

Initializes this instance using the specified context.

Initialize(ObjectContext)

Initializes this instance using the specified context.

IsolationLevelGetting(DbTransaction, DbTransactionInterceptionContext<IsolationLevel>)

Can be implemented in a derived class.

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

Can be implemented in a derived class.

(Inherited from TransactionHandler)
MarkTransactionForPruning(TransactionRow)

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

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)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
Opening(DbConnection, DbConnectionInterceptionContext)

Can be implemented in a derived class.

(Inherited from TransactionHandler)
PruneTransactionHistory()

Removes the transactions marked for deletion.

PruneTransactionHistory(Boolean, Boolean)

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

PruneTransactionHistoryAsync()

Asynchronously removes the transactions marked for deletion.

PruneTransactionHistoryAsync(Boolean, Boolean, CancellationToken)

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

PruneTransactionHistoryAsync(CancellationToken)

Asynchronously removes the transactions marked for deletion.

RolledBack(DbTransaction, DbTransactionInterceptionContext)

Stops tracking the transaction that was rolled back.

RollingBack(DbTransaction, DbTransactionInterceptionContext)

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

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

Can be implemented in a derived class.

(Inherited from TransactionHandler)

Applies to