/// <summary> /// Initializes a new instance of the ReliableSqlConnection class with a given connection string /// and a policy defining whether to retry a request if the connection fails to be opened or a command /// fails to be successfully executed. /// </summary> /// <param name="connectionString">The connection string used to open the SQL Azure database.</param> /// <param name="connectionRetryPolicy">The retry policy defining whether to retry a request if a connection fails to be established.</param> /// <param name="commandRetryPolicy">The retry policy defining whether to retry a request if a command fails to be executed.</param> public ReliableSqlConnection(string connectionString, RetryPolicy connectionRetryPolicy, RetryPolicy commandRetryPolicy) { _underlyingConnection = new SqlConnection(connectionString); _connectionRetryPolicy = connectionRetryPolicy ?? RetryPolicyFactory.CreateNoRetryPolicy(); _commandRetryPolicy = commandRetryPolicy ?? RetryPolicyFactory.CreateNoRetryPolicy(); _underlyingConnection.StateChange += OnConnectionStateChange; _connectionRetryPolicy.RetryOccurred += RetryConnectionCallback; _commandRetryPolicy.RetryOccurred += RetryCommandCallback; }