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
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
executionFunc
Func<TResult>Function to be executed.
retryCount
intLimit of retry executions. If the limit is reached, the exception resulting from the last execution is re-thrown.
Returns
- TResult
Return the result of
executionFunc
if its execution succeeds beforeretryCount
limit is reached.
Type Parameters
TResult
Return type of the
executionFunc
.
Exceptions
- ArgumentNullException
Thrown when
executionFunc
is 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
executionFunc
Func<TResult>Function to be executed.
retryCount
intLimit of retry executions. If the limit is reached, the exception resulting from the last execution is re-thrown.
Returns
- TResult
Return the result of
executionFunc
if its execution succeeds beforeretryCount
limit is reached.
Type Parameters
TResult
Return type of the
executionFunc
.
Exceptions
- ArgumentNullException
Thrown when
executionFunc
is null.