public void GetCodes() { Error = ""; var result = new ObjectParameter("Result", typeof(Int32)); var tranDt = new ObjectParameter("TranDT", typeof(DateTime)); CustomerCodesList.Clear(); CustomerCodesList.Add(""); try { using (var context = new QuoteLogContext()) { var collection = context.usp_QT_Customer_Codes_Get(); foreach (var item in collection) { CustomerCodesList.Add(item.CustomerCode); } _view.cbxCode.DataSource = CustomerCodesList; } } catch (Exception ex) { Error = (ex.InnerException != null) ? "Failed to return customer codes. " + ex.InnerException.Message : "Failed to return customer codes. " + ex.Message; } }