Exemplo n.º 1
0
        private void btnRetrieveAll4Col_Click(object sender, EventArgs e)
        {
            DafestyEntities1 context = new DafestyEntities1();
            var ret = from q in context.Movies1
                      select new { q.MovieTitle, q.Rating, q.MovieType, q.Producer.ProducerName };

            dgvAllMovies.DataSource = ret.ToList();
        }
Exemplo n.º 2
0
        private void btnRetrieveAllbyWaltDisney_Click(object sender, EventArgs e)
        {
            DafestyEntities1 context = new DafestyEntities1();
            var ret = from q in context.Movies1
                      where q.ProducerID == "Walt"
                      select new { q.Producer.ProducerName, q.MovieTitle, q.MovieType };

            dgvAllMovies.DataSource = ret.ToList();
        }
Exemplo n.º 3
0
        private void btnTotalStockofMov_Click(object sender, EventArgs e)
        {
            //LINQ??
            DafestyEntities1 context = new DafestyEntities1();
            var ret = from x in context.Movies1
                      group x by x.MovieType into g
                      select new { MovieType = g.Key, NooFCopies = g.Sum(y => y.TotalStock) };

            dgvAllMovies.DataSource = ret.ToList();

            //LAMBDA??
            //no pure lambda available
        }
Exemplo n.º 4
0
        private void btnRetrieveAll_Click(object sender, EventArgs e)
        {
            //LINQ
            //DafestyEntities1 context = new DafestyEntities1();
            //var ret = from q in context.Movies1
            //          select q;
            //dgvAllMovies.DataSource = ret.ToList();

            //LAMBDA
            DafestyEntities1 context = new DafestyEntities1();

            dgvAllMovies.DataSource = context.Movies1.ToList();
        }
Exemplo n.º 5
0
        private void btnRetrieveAllSciFicbyWarner_Click(object sender, EventArgs e)
        {
            //LINQ
            //DafestyEntities1 context = new DafestyEntities1();
            //var ret = from q in context.Movies1
            //          where q.ProducerID == "Warner" && q.MovieType =="Sci-fi"
            //          select q;
            //dgvAllMovies.DataSource = ret.ToList();

            //LAMBDA
            DafestyEntities1 context = new DafestyEntities1();

            dgvAllMovies.DataSource = context.Movies1.Where(x => x.ProducerID == "Warner" && x.MovieType == "Sci-fi").ToList();
        }
Exemplo n.º 6
0
        private void btnRetrieveRRated_Click(object sender, EventArgs e)
        {
            //LINQ
            //DafestyEntities1 context = new DafestyEntities1();
            //var ret = from q in context.Movies1
            //          where q.Rating == "R"
            //          select q;
            //dgvAllMovies.DataSource = ret.ToList();

            //LAMBDA
            DafestyEntities1 context = new DafestyEntities1();

            dgvAllMovies.DataSource = context.Movies1.Where(x => x.Rating == "R").ToList();
        }
Exemplo n.º 7
0
        private void btnByRPDesc_Click(object sender, EventArgs e)
        {
            //LINQ
            DafestyEntities1 context = new DafestyEntities1();
            var ret = from q in context.Movies1
                      orderby q.RentalPrice descending
                      select q;

            dgvAllMovies.DataSource = ret.ToList();

            //LAMBDA
            //DafestyEntities1 context = new DafestyEntities1();
            //dgvAllMovies.DataSource = context.Movies1.OrderByDescending(x => x.RentalPrice).ToList();
        }
Exemplo n.º 8
0
        private void btnRetrieveRRated3Col_Click(object sender, EventArgs e)
        {
            //LINQ
            DafestyEntities1 context = new DafestyEntities1();
            var ret = from q in context.Movies1
                      where q.Rating == "R"
                      select new { q.VideoCode, q.MovieTitle, q.RentalPrice };

            dgvAllMovies.DataSource = ret.ToList();

            //LAMBDA
            //DafestyEntities1 context = new DafestyEntities1();
            //dgvAllMovies.DataSource = context.Movies1.Where(x => x.Rating == "R").Select(q => new {q.VideoCode, q.MovieTitle, q.RentalPrice}).ToList();
        }
Exemplo n.º 9
0
        private void btnByMovTitleAsc_Click(object sender, EventArgs e)
        {
            //LINQ
            DafestyEntities1 context = new DafestyEntities1();
            var ret = from q in context.Movies1
                      orderby q.MovieTitle
                      select q;

            dgvAllMovies.DataSource = ret.ToList();

            //LAMBDA
            //DafestyEntities1 context = new DafestyEntities1();
            //dgvAllMovies.DataSource = context.Movies1.OrderBy(x => x.MovieTitle).ToList();
        }
Exemplo n.º 10
0
        private void btnTotalActMov_Click(object sender, EventArgs e)
        {
            //LINQ
            DafestyEntities1 context = new DafestyEntities1();
            var ret = from q in context.Movies1
                      where q.MovieType == "Action"
                      select q;

            lblShow.Text = ret.Count().ToString();

            //LAMBDA
            //DafestyEntities1 context = new DafestyEntities1();
            //int? totalActionMov = context.Movies1.Count(x => x.MovieType == "Action");
            //lblShow.Text = totalActionMov.ToString();
        }
Exemplo n.º 11
0
        private void btnAvgPriceComMov_Click(object sender, EventArgs e)
        {
            //LINQ??
            DafestyEntities1 context = new DafestyEntities1();
            var ret = from q in context.Movies1
                      where q.MovieType == "Comedy"
                      select q.RentalPrice;

            lblShow.Text = ret.Average().ToString();

            //LAMBDA
            //DafestyEntities1 context = new DafestyEntities1();
            //double? avgPriceComMov = context.Movies1.Where(y => y.MovieType == "Comedy").Average(x => x.RentalPrice);
            //lblShow.Text = avgPriceComMov.ToString();
        }
Exemplo n.º 12
0
        private void btnTotalStockofActMov_Click(object sender, EventArgs e)
        {
            //LINQ?? how to get action only ??
            //DafestyEntities1 context = new DafestyEntities1();
            //var ret = from x in context.Movies1
            //          group x by x.MovieType into g
            //          //group x by (x.MovieType == "Action") into g
            //          //select new { g.Key.Where() copies = g.Sum(y => y.TotalStock) };
            //lblShow.Text = ret.ToString();


            //LAMBDA
            DafestyEntities1 context = new DafestyEntities1();
            int?totalStockActionMov  = context.Movies1.Where(y => y.MovieType == "Action").Sum(x => x.TotalStock);

            lblShow.Text = totalStockActionMov.ToString();
        }