private IDictionary<string, Order> _cache;
private string _connectionString;
public ctor(IDictionary<string, Order> cache, string connectionString)
_connectionString = connectionString;
public Order LoadOrderInfo(string orderCode)
Stopwatch stopWatch = new Stopwatch();
if (string.IsNullOrEmpty(orderCode))
throw new ArgumentException("OrderCode doen not provided.");
if (_cache.ContainsKey(orderCode))
"Elapsed - {0}", stopWatch.Elapsed);
return _cache[orderCode];
"SELECT OrderID, CustomerID, TotalMoney" +
" FROM dbo.Orders where OrderCode='{0}'";
string query = string.Format(queryTemplate, orderCode);
using (SqlConnection connection = new SqlConnection(_connectionString))
using (SqlCommand command = new SqlCommand(query, connection))
SqlDataReader reader = command.ExecuteReader();
if (!_cache.ContainsKey(orderCode))
_cache[orderCode] = order;
logger.Log("INFO", "Elapsed - {0}", stopWatch.Elapsed);
logger.Log("INFO", "Elapsed - {0}", stopWatch.Elapsed);
logger.Log("ERROR", ex.Message);
throw new ApplicationException("Error");