I have a fairly large web application using LINQ-TO-SQL running on Azure and am experiencing Transient errors from SQL-Azure and therefore you need to retry. I know the Transient Fault Handling Framework and a few sites that provide usage examples, but it looks like you need to wrap all your LINQ queries in something like this:
RetryPolicy retry = new RetryPolicy<MyRetryStrategy>(5, TimeSpan.FromSeconds(5)); Result = retry.ExecuteAction(() => { β¦ LINQ query here... });
With hundreds of LINQ queries in my data layer, this seems really messy, as well as the fact that many times the query is not actually executed until the results are listed. For example, most of my functions in my data layer return IQueryable <> to the business level (which makes them more flexible than returning a list). So this means that you have to lure your level of business logic with re-database logic - ugly.
So, I think, in order to preserve the retry logic in the data layer, I would have to put .ToList () on all my requests so that they execute right there, and not in the layer above.
I am very sorry that there is a way to implement the retry logic in some base class and it is not necessary to change all my requests. It seems that EF will also have this problem.
Is the real answer to try talking to the SQL-Azure team to automatically retry, so we donβt have to worry about that in our code?
source share