Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was able to get started by looking here: <a href="http://hmadrigal.wordpress.com/2012/04/23/automatic-retries-using-the-transient-fault-handling-from-enterprise-libraries-entlib/" rel="nofollow">http://hmadrigal.wordpress.com/2012/04/23/automatic-retries-using-the-transient-fault-handling-from-enterprise-libraries-entlib/</a></p> <p>You just have to write your own detection strategy class. In my case it looks like this:</p> <pre><code>public class EntityFrameworkTransientErrorDetectionStrategy : ITransientErrorDetectionStrategy { #region ITransientErrorDetectionStrategy Members public bool IsTransient(Exception ex) { if (ex is SqlException) { return true; } else return false; } #endregion } </code></pre> <p>In my repository constructor I have this:</p> <pre><code>_retryStrategy = new FixedInterval(_retryLimit, new TimeSpan(0, 0, 0, 0, 500)); _retryPolicy = new RetryPolicy&lt;EntityFrameworkTransientErrorDetectionStrategy&gt;(_retryStrategy); // use our custom detection strategy _retryPolicy.Retrying += (sender, args) =&gt; { // Log any retries as warnings _logger.WarnFormat("Retry {0} of {1} due to exception: {2}", args.CurrentRetryCount, _retryLimit, args.LastException); }; </code></pre> <p>A typical repository method:</p> <pre><code>public override HarvesterDomain.Source SelectSource(Guid id) { HarvesterDomain.Source source = null; _retryPolicy.ExecuteAction(() =&gt; { var contextSource = _context.Sources.Where(s =&gt; s.Id == id).FirstOrDefault(); if (contextSource != null) source = contextSource.ToHarvesterDomainSource(); }); return source; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload