public T One <T>(IObjectMapper <T> mapper, string query, params object[] args) { var count = 5; var res = default(T); while (count > 0) { count--; var dbConnection = connectionService.Get(); IDbCommand dbCommand = null; IDataReader reader = null; try { dbConnection.Open(); dbCommand = dbConnection.CreateCommand(); logger.Debug(string.Format("(" + count + ") " + query, args)); dbCommand.CommandText = string.Format(query, args); reader = dbCommand.ExecuteReader(); res = mapper.Get(reader); } catch (DbException e) { logger.Error($"SQLiteException:{e.Message}\n{e.StackTrace}\n{query}", e); if (count == 0) { break; } }finally { reader?.Close(); dbCommand?.Dispose(); connectionService.Release(dbConnection); } return(res); } logger.Error("Max Retry Exception"); throw new DbMaxRetryException(); }