{"action":"created","issue":{"url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/230","labels_url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/230/labels{/name}","comments_url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/230/comments","events_url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/230/events","html_url":"https://github.com/StackExchange/dapper-dot-net/issues/230","id":53552410,"number":230,"title":"Retry mechanism for transient errors","user":{"login":"PaulDMendoza","id":1039795,"avatar_url":"https://avatars.githubusercontent.com/u/1039795?v=3","gravatar_id":"","url":"https://api.github.com/users/PaulDMendoza","html_url":"https://github.com/PaulDMendoza","followers_url":"https://api.github.com/users/PaulDMendoza/followers","following_url":"https://api.github.com/users/PaulDMendoza/following{/other_user}","gists_url":"https://api.github.com/users/PaulDMendoza/gists{/gist_id}","starred_url":"https://api.github.com/users/PaulDMendoza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaulDMendoza/subscriptions","organizations_url":"https://api.github.com/users/PaulDMendoza/orgs","repos_url":"https://api.github.com/users/PaulDMendoza/repos","events_url":"https://api.github.com/users/PaulDMendoza/events{/privacy}","received_events_url":"https://api.github.com/users/PaulDMendoza/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-06T19:26:47Z","updated_at":"2015-08-26T15:09:07Z","closed_at":null,"body":"It would be great if there was a simple additional optional parameters on the Query and Execute methods for retrying a query automatically to handle transient errors."},"comment":{"url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/comments/135055135","html_url":"https://github.com/StackExchange/dapper-dot-net/issues/230#issuecomment-135055135","issue_url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/230","id":135055135,"user":{"login":"devlead","id":1647294,"avatar_url":"https://avatars.githubusercontent.com/u/1647294?v=3","gravatar_id":"","url":"https://api.github.com/users/devlead","html_url":"https://github.com/devlead","followers_url":"https://api.github.com/users/devlead/followers","following_url":"https://api.github.com/users/devlead/following{/other_user}","gists_url":"https://api.github.com/users/devlead/gists{/gist_id}","starred_url":"https://api.github.com/users/devlead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devlead/subscriptions","organizations_url":"https://api.github.com/users/devlead/orgs","repos_url":"https://api.github.com/users/devlead/repos","events_url":"https://api.github.com/users/devlead/events{/privacy}","received_events_url":"https://api.github.com/users/devlead/received_events","type":"User","site_admin":false},"created_at":"2015-08-26T15:09:06Z","updated_at":"2015-08-26T15:09:06Z","body":"@ianlee74 one could probably do something like below (this could easily be wrapped in a \"utility/contrib\" function)\r\n```csharp\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing Dapper;\r\nusing Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling;\r\n\r\nnamespace TransientDapper\r\n{\r\n    internal static class Program\r\n    {\r\n        private class Customer\r\n        {\r\n            public int CustomerId { get; set; }\r\n        }\r\n\r\n        private static void Main()\r\n        {\r\n            const int retryCount = 4;\r\n            const int minBackoffDelayMilliseconds = 2000;\r\n            const int maxBackoffDelayMilliseconds = 8000;\r\n            const int deltaBackoffMilliseconds = 2000;\r\n\r\n            var exponentialBackoffStrategy =\r\n                new ExponentialBackoff(\r\n                    \"exponentialBackoffStrategy\",\r\n                    retryCount,\r\n                    TimeSpan.FromMilliseconds(minBackoffDelayMilliseconds),\r\n                    TimeSpan.FromMilliseconds(maxBackoffDelayMilliseconds),\r\n                    TimeSpan.FromMilliseconds(deltaBackoffMilliseconds)\r\n                    );\r\n\r\n            var manager = new RetryManager(\r\n                new List<RetryStrategy>\r\n                {\r\n                    exponentialBackoffStrategy\r\n                },\r\n                exponentialBackoffStrategy.Name\r\n                );\r\n\r\n            RetryManager.SetDefault(manager);\r\n\r\n            using (var conn = new ReliableSqlConnection(\"Server=localhost;Database=master;Trusted_Connection=True;\"))\r\n            {\r\n                conn.Open();\r\n                var customers = conn.CommandRetryPolicy.ExecuteAction(\r\n                    () => conn.Query<Customer>(\r\n                        \"SELECT 1 AS CustomerId\"\r\n                        )\r\n                    );\r\n                Console.WriteLine(\r\n                    \"Result: {0}\",\r\n                    customers.Select(customer => customer.CustomerId).FirstOrDefault()\r\n                    );\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nThis is using these Nuget packages\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Dapper\" version=\"1.42\" targetFramework=\"net45\" />\r\n  <package id=\"EnterpriseLibrary.TransientFaultHandling\" version=\"6.0.1304.0\" targetFramework=\"net45\" />\r\n  <package id=\"EnterpriseLibrary.TransientFaultHandling.Data\" version=\"6.0.1304.1\" targetFramework=\"net45\" />\r\n</packages>\r\n```"}}