Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AzureNHibernateRepository : NHibernateRepository
- {
- private const int maxRetries = 5;
- public AzureNHibernateRepository ( INHibernateUnitOfWork uow ) : base ( uow )
- {}
- public void EnsureCleanup ( Action block )
- {
- ensureCleanup(block);
- }
- protected override void ensureCleanup(Action block)
- {
- var retries = 0;
- while ( retries < maxRetries )
- {
- retries ++;
- try
- {
- block.Invoke();
- return;
- }
- catch (DbException dbException )
- {
- this.unitOfWork.CleanUp ();
- if (!dbException.Message.Contains("transport-level error")) throw;
- if ( retries == maxRetries ) throw dbException;
- }
- catch (Exception)
- {
- this.unitOfWork.CleanUp();
- throw;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment