EntLib 5.0 Data Acces Block and Transient Fault Handling

Topics: Data Access Application Block, Windows Azure Integration Pack
Dec 13, 2011 at 4:33 PM


Is there an example of how to integrate the EntLib 5.0 Data Acces Application Block with the Transient Fault Handling Application Block that is in the Enterprise Library 5.0 Integration Pack for Windows Azure?


Dec 14, 2011 at 5:07 AM
Edited Dec 14, 2011 at 5:07 AM

From the Developer's Guide for the EntLib Azure Integration Pack

Applications access SQL Azure databases in exactly the same way they access locally installed SQL Server 
instances using the managed ADO.NET data access classes, Enterprise Library Data Access Application 
Block (DAAB), OData, native ODBC, PHP, Ruby, or JDBC data access technologies.

Then take a look at the SurveySqlStore class in the Dev Guide:

public void SaveSurvey(string connectionString, SurveyData surveyData)
    using (var dataContext = new SurveySqlDataContext(connectionString))
            this.retryPolicy.ExecuteAction(() => dataContext.SubmitChanges());
        catch (SqlException ex)

Of course the above example is for LINQ to SQL so we need to change to use Data Access Application Block.
Something similar would look like this:

Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>("WindowsAzureSQL");

using (DbCommand cmd = db.GetStoredProcCommand("usp_DoSomething"))
    RetryPolicy retryPolicy = RetryPolicyFactory.GetDefaultSqlCommandRetryPolicy();
    retryPolicy.ExecuteAction(() => db.ExecuteNonQuery(cmd));

Randy Levy
Enterprise Library support engineer