Your company has a mobile app that accesses an Azure SQL Database. You want to ensure that the app is developed to handle temporary Azure service interruptions due to connectivity issues. You must ensure that whenever a connection fails, a new attempt is made, up to four times. A variable named connectionString represents the connection string to Azure SQL Database.
You need to complete the code.
How should you complete the code? Select correct placeholder values.
var x = PLACEHOLDER 1;
using (var conn = new PLACEHOLDER 2(PLACEHOLDER 3))
You should use the following code:
var x = new RetryPolicy<SqlDatabaseTransientErrorDetectionStrategy>(4);
using (var conn = new ReliableSqlConnection(connectionString, x))
The first statement creates a RetryPolicy instance that represents how retries should occur in the event of a connection failure. The class accepts a generic type parameter that specifies the transient detection strategy. In this scenario, it specifies the SqlDatabaseTransientErrorDetectionStrategy class. The constructor accepts a parameter that specifies the number of retries, which is four in this scenario.
The next statement creates an instance of ReliableSqlConnection, passing to it the connection string and the RetryPolicy instance. This represents a connection to the database with the retry policy.
You should not set the variable x to 4. You should set this to a RetryPolicy instance.
You should not create an instance of SqlConnection. This class does not support retry policies.