using DevExpress.DataAccess.Sql; using DevExpress.DataAccess.Sql.DataApi; namespace EnvelopeGenerator.ReceiverUI.Data { public class Customer { static List currentCustomers = new List(); public static List Customers { get { return currentCustomers; } } static Customer() { try { SqlDataSource ds = new SqlDataSource("NWindConnectionString"); SelectQuery query = SelectQueryFluentBuilder .AddTable("Customers") .SelectAllColumns() .Build("Customers"); ds.Queries.Add(query); ds.RebuildResultSchema(); ds.Fill(); ITable src = ds.Result["Customers"]; foreach(var row in src) { currentCustomers.Add(new Customer() { CustomerID = row.GetValue("CustomerID"), Address = row.GetValue("Address"), CompanyName = row.GetValue("CompanyName"), ContactName = row.GetValue("ContactName"), ContactTitle = row.GetValue("ContactTitle"), Country = row.GetValue("Country"), City = row.GetValue("City"), Fax = row.GetValue("Fax"), Phone = row.GetValue("Phone"), PostalCode = row.GetValue("PostalCode"), Region = row.GetValue("Region") }); } } catch { currentCustomers.Add(new Customer() { Address = "Obere Str. 57", City = "Berlin", CompanyName = "Alfreds Futterkiste", ContactName = "Maria Anders", ContactTitle = "Sales Representative", Country = "Germany", CustomerID = "ALFKI", Fax = "030-0076545", Phone = "030-0074321", PostalCode = "12209" }); } } public string CustomerID { get; set; } public string CompanyName { get; set; } public string ContactName { get; set; } public string ContactTitle { get; set; } public string Address { get; set; } public string City { get; set; } public string PostalCode { get; set; } public string Region { get; set; } public string Country { get; set; } public string Phone { get; set; } public string Fax { get; set; } } }