public Createrental ( global rental_id, global rental_date, Nullable |
||
rental_id | global | |
rental_date | global | |
return_date | Nullable |
|
inventory_id | global | |
customer_id | global | |
staff_id | global | |
last_update | global | |
return |
public override SRental[] GetRentals(int customerid) { List <SRental> srentlist = new List <SRental>(); using (SakilaEntities dc = new SakilaEntities()) { var model = from r in dc.rentals where r.customer_id == customerid orderby(r.return_date) select r; List <rental> rentalList = model.ToList <rental>(); simulator.PerformanceSimulation(); for (int i = 0; i < rentalList.Count; i++) { SRental rental = new SRental(); if (rentalList[i].return_date.HasValue) { rental = rental.Createrental(rentalList[i].rental_id, rentalList[i].rental_date, rentalList[i].return_date, rentalList[i].inventory_id, rentalList[i].customer_id, rentalList[i].staff_id, rentalList[i].last_update); } else { rental = rental.Createrental(rentalList[i].rental_id, rentalList[i].rental_date, rentalList[i].inventory_id, rentalList[i].customer_id, rentalList[i].staff_id, rentalList[i].last_update); } rental.Filmtitle = rentalList[i].inventory.film.title; srentlist.Add(rental); } } return(srentlist.ToArray <SRental>()); }
public override SRental GetRentalByPayment(int id) { //a deliberate inefficient query List <SRental> srentlist = new List <SRental>(); SRental lightweightrental = new SRental(); using (SakilaEntities dc = new SakilaEntities()) { var model = from r in dc.payments where r.payment_id == id select r; List <payment> pList = model.ToList <payment>(); payment p = pList[0]; var rentalModel = from r in dc.rentals where r.rental_id == p.rental_id orderby(r.return_date) //this is not neccessary but put in here for analysis (SQL end) select r; List <rental> rentalList = rentalModel.ToList <rental>(); simulator.PerformanceSimulation(); rental hwrental = rentalList[0]; if (hwrental.return_date.HasValue) { lightweightrental = lightweightrental.Createrental(hwrental.rental_id, hwrental.rental_date, hwrental.return_date, hwrental.inventory_id, hwrental.customer_id, hwrental.staff_id, hwrental.last_update); } else { lightweightrental = lightweightrental.Createrental(hwrental.rental_id, hwrental.rental_date, hwrental.inventory_id, hwrental.customer_id, hwrental.staff_id, hwrental.last_update); } lightweightrental.Filmtitle = hwrental.inventory.film.title; } return(lightweightrental); }
public override SRental[] GetRentals(int customerid) { List<SRental> srentlist = new List<SRental>(); using (SakilaEntities dc = new SakilaEntities()) { var model = from r in dc.rentals where r.customer_id == customerid orderby (r.return_date) select r; List<rental> rentalList = model.ToList<rental>(); simulator.PerformanceSimulation(); for (int i = 0; i < rentalList.Count; i++) { SRental rental = new SRental(); if (rentalList[i].return_date.HasValue) { rental = rental.Createrental(rentalList[i].rental_id, rentalList[i].rental_date, rentalList[i].return_date, rentalList[i].inventory_id, rentalList[i].customer_id, rentalList[i].staff_id, rentalList[i].last_update); } else { rental = rental.Createrental(rentalList[i].rental_id, rentalList[i].rental_date, rentalList[i].inventory_id, rentalList[i].customer_id, rentalList[i].staff_id, rentalList[i].last_update); } rental.Filmtitle = rentalList[i].inventory.film.title; srentlist.Add(rental); } } return srentlist.ToArray<SRental>(); }
public override SRental GetRentalByPayment(int id) { //a deliberate inefficient query List<SRental> srentlist = new List<SRental>(); SRental lightweightrental = new SRental(); using (SakilaEntities dc = new SakilaEntities()) { var model = from r in dc.payments where r.payment_id == id select r; List<payment> pList = model.ToList<payment>(); payment p = pList[0]; var rentalModel = from r in dc.rentals where r.rental_id == p.rental_id orderby (r.return_date) //this is not neccessary but put in here for analysis (SQL end) select r; List<rental> rentalList = rentalModel.ToList<rental>(); simulator.PerformanceSimulation(); rental hwrental = rentalList[0]; if (hwrental.return_date.HasValue) { lightweightrental = lightweightrental.Createrental(hwrental.rental_id, hwrental.rental_date, hwrental.return_date, hwrental.inventory_id, hwrental.customer_id, hwrental.staff_id, hwrental.last_update); } else { lightweightrental = lightweightrental.Createrental(hwrental.rental_id, hwrental.rental_date, hwrental.inventory_id, hwrental.customer_id, hwrental.staff_id, hwrental.last_update); } lightweightrental.Filmtitle = hwrental.inventory.film.title; } return lightweightrental; }