示例#1
0
        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 SRental Createrental(global::System.Int32 rental_id, global::System.DateTime rental_date, global::System.Int32 inventory_id, global::System.Int32 customer_id, global::System.Byte staff_id, global::System.DateTime last_update)
        {
            SRental rental = new SRental();

            rental.rental_id    = rental_id;
            rental.rental_date  = rental_date;
            rental.inventory_id = inventory_id;
            rental.customer_id  = customer_id;
            rental.staff_id     = staff_id;
            rental.last_update  = last_update;
            return(rental);
        }
示例#3
0
        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);
        }
示例#4
0
        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>();
        }
示例#5
0
        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 SRental Createrental(global::System.Int32 rental_id, global::System.DateTime rental_date, Nullable<global::System.DateTime> return_date, global::System.Int32 inventory_id, global::System.Int32 customer_id, global::System.Byte staff_id, global::System.DateTime last_update)
 {
     SRental rental = new SRental();
     rental.rental_id = rental_id;
     rental.rental_date = rental_date;
     rental.return_date = return_date;
     rental.inventory_id = inventory_id;
     rental.customer_id = customer_id;
     rental.staff_id = staff_id;
     rental.last_update = last_update;
     return rental;
 }