Class SqlExecutionHelper
- Namespace
- CMS.DataEngine
- Assembly
- CMS.DataEngine.dll
Contains utility methods for SQL execution retries.
public class SqlExecutionHelper : AbstractHelper<SqlExecutionHelper>
- Inheritance
-
objectSqlExecutionHelper
- Inherited Members
- Extension Methods
Constructors
SqlExecutionHelper()
public SqlExecutionHelper()
Methods
ExecuteWithDeadlockRetryInternal<TResult>(Func<TResult>, int)
Executes the given executionFunc while catching exception resulting from the execution.
If the exception thrown contains Microsoft.Data.SqlClient.SqlException as its inner exception and the Microsoft.Data.SqlClient.SqlException.Number
equals to 1205 (deadlock), the execution is retried.
The execution is never retried if IsInTransaction indicates the execution is part of a transaction.
If the retry limit is reached, the exception resulting from the last execution is re-thrown.
protected virtual TResult ExecuteWithDeadlockRetryInternal<TResult>(Func<TResult> executionFunc, int retryCount)
Parameters
executionFuncFunc<TResult>Function to be executed.
retryCountintLimit of retry executions. If the limit is reached, the exception resulting from the last execution is re-thrown.
Returns
- TResult
Return the result of
executionFuncif its execution succeeds beforeretryCountlimit is reached.
Type Parameters
TResultReturn type of the
executionFunc.
Exceptions
- ArgumentNullException
Thrown when
executionFuncis null.
ExecuteWithDeadlockRetry<TResult>(Func<TResult>, int)
Executes the given executionFunc while catching exception resulting from the execution.
If the exception thrown contains Microsoft.Data.SqlClient.SqlException as its inner exception and the Microsoft.Data.SqlClient.SqlException.Number
equals to 1205 (deadlock), the execution is retried.
The execution is never retried if IsInTransaction indicates the execution is part of a transaction.
If the retry limit is reached, the exception resulting from the last execution is re-thrown.
public static TResult ExecuteWithDeadlockRetry<TResult>(Func<TResult> executionFunc, int retryCount)
Parameters
executionFuncFunc<TResult>Function to be executed.
retryCountintLimit of retry executions. If the limit is reached, the exception resulting from the last execution is re-thrown.
Returns
- TResult
Return the result of
executionFuncif its execution succeeds beforeretryCountlimit is reached.
Type Parameters
TResultReturn type of the
executionFunc.
Exceptions
- ArgumentNullException
Thrown when
executionFuncis null.