SqlRetryLogicOption Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides the retry logic parameters to create an instance of the SqlRetryLogicBaseProvider class by using SqlConfigurableRetryFactory methods.
public ref class SqlRetryLogicOption sealed
[System.Serializable]
public sealed class SqlRetryLogicOption
public sealed class SqlRetryLogicOption
[<System.Serializable>]
type SqlRetryLogicOption = class
type SqlRetryLogicOption = class
Public NotInheritable Class SqlRetryLogicOption
- Inheritance
-
SqlRetryLogicOption
- Attributes
Examples
The following sample declares a SqlRetryLogicOption object that is configured to apply retry logic for the error number 102
for a maximum of 5
times and 3
to 60
seconds gap time between each run. It will only work for the SELECT SQL statements assigned to the RetryLogicProvider.
using System;
using System.Text.RegularExpressions;
using Microsoft.Data.SqlClient;
class RetryLogicSample
{
static void Main(string[] args)
{
var RetryLogicOption = new SqlRetryLogicOption()
{
NumberOfTries = 5,
// Declare the error number 102 as a transient error to apply the retry logic when it occurs.
TransientErrors = new int[] { 102 },
// When a SqlCommand executes out of a transaction,
// the retry logic will apply if it contains a 'select' keyword.
AuthorizedSqlCondition = x => string.IsNullOrEmpty(x)
|| Regex.IsMatch(x, @"\b(SELECT)\b", RegexOptions.IgnoreCase),
DeltaTime = TimeSpan.FromSeconds(1),
MaxTimeInterval = TimeSpan.FromSeconds(60),
MinTimeInterval = TimeSpan.FromSeconds(3)
};
}
}
Constructors
SqlRetryLogicOption() |
Properties
AuthorizedSqlCondition |
Sets a pre-retry validation function on the CommandText to only include specific SQL statements. |
DeltaTime |
Sets the gap time interval as a TimeSpan object. |
MaxTimeInterval |
Sets the allowed maximum gap time interval as a TimeSpan object. |
MinTimeInterval |
Sets the minimum allowed gap time interval as a TimeSpan object. |
NumberOfTries |
Sets the number of times to try and execute the function. |
TransientErrors |
Sets the list of transient error numbers on which to retry when they occur. |