C# Class EnterpriseWebLibrary.DataAccess.DataAccessMethods

A collection of static methods related to data access.
Show file Open project: enduracode/enterprise-web-library Class Usage Examples

Public Methods

Method Description
RetryOnDeadlock ( System.Action method ) : void

Retries the given operation in the case of a deadlock (when using pessimistic concurrency) or snapshot isolation error (when using optimistic concurrency) until it succeeds. NEVER EVER use this inside a transaction because SQL will automatically kill the transaction in the case of a deadlock, and it's unusable after that point. In the case of Snapshots, the same snapshot from the beginning of the transaction will be used every single time, and so the operation will fail every single time. So, again, DO NOT use this inside a transaction. When using this method, it is important that DeadLockableMethod does not produce any side effects (changing state, sending an email, etc.). Undoing/resetting side effects at the beginning of the block of code to be retried is an acceptable approach here (there is no way to undo certain operations, such as sending an email, obviously).

Private Methods

Method Description
CompareCommandConditionTypes ( InlineDbCommandCondition x, InlineDbCommandCondition y ) : int
CreateDbConnectionException ( DatabaseInfo databaseInfo, string action, Exception innerException ) : Exception
CreateStandbyServerModificationException ( ) : Exception
GetDbName ( DatabaseInfo databaseInfo ) : string

Method Details

RetryOnDeadlock() public static method

Retries the given operation in the case of a deadlock (when using pessimistic concurrency) or snapshot isolation error (when using optimistic concurrency) until it succeeds. NEVER EVER use this inside a transaction because SQL will automatically kill the transaction in the case of a deadlock, and it's unusable after that point. In the case of Snapshots, the same snapshot from the beginning of the transaction will be used every single time, and so the operation will fail every single time. So, again, DO NOT use this inside a transaction. When using this method, it is important that DeadLockableMethod does not produce any side effects (changing state, sending an email, etc.). Undoing/resetting side effects at the beginning of the block of code to be retried is an acceptable approach here (there is no way to undo certain operations, such as sending an email, obviously).
public static RetryOnDeadlock ( System.Action method ) : void
method System.Action
return void