Hi,
The usage of Enterprise Library is very like the usage of ADO.NET + strongly typed DataSet. To implement Retry, you need Try..Catch + a loop, just like the code mentioned below:
http://blogs.msdn.com/b/bartr/archive/2010/06/18/sql-azure-connection-retry.aspx
You may also put the retry logic in an extension method, which would make your code cleaner. For instance, you may write an extension method for UpdateDataSet method:
public static class Utility
{
public static int UpdateDataSetWithRetry(this Database db,int retrytimes)
{
int returnvalue = 0;
for (int i = 0; i < retrytimes; i++)
{
try
{
//...
// call db.UpdateDataSet() method
//...
}
catch (SqlException ex)
{
//...
}
catch (Exception ex)
{
// catch other exceptions if needed
}
}
return returnvalue;
}
}
class Program
{
static void Main(string[] args)
{
Database db = DatabaseFactory.CreateDatabase();
//...
// Retry 3 times if failed to update.
db.UpdateDataSetWithRetry(3);
}
}
Learn more about extension method:
http://msdn.microsoft.com/en-us/library/bb383977.aspx
Please remember to mark the replies as answers if they help and unmark them if they provide no help. Windows Azure Platform China Blog: http://blogs.msdn.com/azchina/default.aspx