public override SCustomer[] GetCustomersByText(string searchtext) { List <SCustomer> scustomerlist = new List <SCustomer>(); using (SakilaEntities dc = new SakilaEntities()) { var model = from c in dc.customers where c.first_name.Contains(searchtext) || c.last_name.Contains(searchtext) orderby(c.first_name) select c; List <customer> contactList = model.ToList <customer>(); foreach (customer cust in contactList) { //high freq sql calls again and again to reconstruct object, terrible pattern //this should increase the sql calls by a magnitude of 2 orders (in a production environment) var mymodel = from c in dc.customers where c.customer_id == cust.customer_id select c; List <customer> slowcustomerlist = mymodel.ToList <customer>(); customer locCust = slowcustomerlist[0]; SCustomer scustomer = new SCustomer(); scustomer = scustomer.Createcustomer( locCust.customer_id, locCust.store_id, locCust.first_name, locCust.last_name, locCust.address_id, locCust.active, locCust.create_date, locCust.last_update, locCust.email); scustomerlist.Add(scustomer); } } simulator.PerformanceSimulation(); return(scustomerlist.ToArray <SCustomer>()); }
public override bool PayForMovie(byte staffid, byte customerid, byte rentalid, double paymentAmount) { payment payment = new payment(); payment.amount = (decimal)paymentAmount; payment.customer_id = customerid; payment.staff_id = staffid; payment.rental_id = rentalid; using (SakilaEntities dc = new SakilaEntities()) { simulator.PerformanceSimulation(); dc.AddTopayments(payment); dc.SaveChanges(); } return(true); }