title: WCF RIA Services and SQL Azure transient fault handling
body: <p>Is there any published guidance for handling transient fault scenarios in SQL Azure when using WCF RIA Services backed by Entity Framework and/or Linq to SQL?</p>
  
  <p>We have studied the CAT retry library (<a href="http://windowsazurecat.com/2011/02/transient-fault-handling-framework/" rel="nofollow">Transient Fault Handling Framework for SQL Azure</a>) and documentation (<a href="http://social.technet.microsoft.com/wiki/contents/articles/4235.retry-logic-for-transient-failures-in-sql-azure.aspx" rel="nofollow">Retry Logic for Transient Failures in SQL Azure</a>), particularly the sections as they relate to Entity Framework and Linq to SQL.</p>
  
  <p>For example, in the case of Linq to SQL, we are instructed to wrap our query/update code into an ExecuteAction and execute it with a RetryPolicy.</p>
  
  <p>This article (<a href="http://www.soulier.ch/?p=773&amp;lang=en" rel="nofollow">Silverlight 4, EF 4, RIA Services &amp; Windows Azure together</a>) suggests that the best we can hope for is to add resiliancy to the connection. However, it appears that we may get the result we want by overriding the PersistChangeSet method on LinqToEntitiesDomainService and LinqToSqlDomainService and adding our retry there.</p>
  
  <p>e.g. (Pseudo code)</p>
  
  <pre><code> protected override bool PersistChangeSet()
   {
      e.Result = retry.ExecuteAction(() =&gt;
          {
              return base.PersistChangeSet();
          });
  
      return e.Result;
   }
  </code></pre>
  
  <p>Any thoughts to this approach? Is there any documentation or guidance out there, specifically as relates to RIA Services?</p>