示例#1
0
        private void btnEx13_Click(object sender, EventArgs e)
        {
            DafestyEntities context = new DafestyEntities();
            //var qry = from x in context.Movies select new { x.MovieTitle, x.MovieType, x.Producer.ProducerName };
            var qry = context.Movies.Select(x => new { x.MovieTitle, x.MovieType, x.Producer.ProducerName });

            dataGridView1.DataSource = qry.ToList();
        }
示例#2
0
        private void btnEx6_Click(object sender, EventArgs e)
        {
            DafestyEntities context = new DafestyEntities();
            var             qry     = (from x in context.Movies where x.MovieType == "Action" select x).Count().ToString();

            //var qry = context.Movies.Where(x => x.MovieType == "Action").Count().ToString();
            lblEx6Ans.Text    = qry;
            lblEx6Ans.Visible = true;
        }
示例#3
0
        private void btnEx8_Click(object sender, EventArgs e)
        {
            DafestyEntities context = new DafestyEntities();
            var             qry     = (from x in context.Movies where x.MovieType == "Comedy" select x).Average(x => x.RentalPrice).ToString();

            //var qry = context.Movies.Where(x => x.MovieType == "Comedy").Average(y=>y.RentalPrice).ToString();
            lblEx8Ans.Text    = qry;
            lblEx8Ans.Visible = true;
        }
示例#4
0
        private void btnEx7_Click(object sender, EventArgs e)
        {
            DafestyEntities context = new DafestyEntities();
            //var qry = (from x in context.Movies where x.MovieType == "Action" select x).Sum(x=>x.TotalStock).ToString();
            var qry = context.Movies.Where(x => x.MovieType == "Action").Sum(x => x.TotalStock).ToString();

            lblEx7Ans.Text    = qry;
            lblEx7Ans.Visible = true;
            //dataGridView1.DataSource = qry.ToList();
        }
示例#5
0
        private void btnEx5_Click(object sender, EventArgs e)
        {
            DafestyEntities context = new DafestyEntities();
            //var qry = from x in context.Movies where x.ProducerID == "Warner" && x.MovieType=="Sci-fi" select x;
            var qry = context.Movies.Where(x => x.ProducerID == "Warner" && x.MovieType == "Sci-fi").ToList();

            //List<Movy> clst = qry.ToList<Movy>();
            //dataGridView1.DataSource = clst;
            dataGridView1.DataSource = qry;
        }
示例#6
0
        private void btnEx4_Click(object sender, EventArgs e)
        {
            DafestyEntities context = new DafestyEntities();
            var             qry     = from x in context.Movies where x.Rating == "R"  select x;
            //var qry = context.Movies.Where(x => x.Rating == "R").ToList();
            List <Movy> clst = qry.ToList <Movy>();

            dataGridView1.DataSource = clst;
            //dataGridView1.DataSource = qry;
        }
示例#7
0
        private void btnEx3_Click(object sender, EventArgs e)
        {
            DafestyEntities context = new DafestyEntities();
            //var qry = from x in context.Movies orderby x.RentalPrice descending select x;
            var qry = context.Movies.OrderByDescending(x => x.RentalPrice).ToList();

            //List<Movy> clst = qry.ToList<Movy>();
            //dataGridView1.DataSource = clst;
            dataGridView1.DataSource = qry;
        }
示例#8
0
        private void btnEx2_Click(object sender, EventArgs e)
        {
            DafestyEntities context = new DafestyEntities();
            var             qry     = from x in context.Movies orderby x.MovieTitle select x;
            //var qry = context.Movies.OrderBy(x => x.MovieTitle).ToList();
            List <Movy> clst = qry.ToList <Movy>();

            dataGridView1.DataSource = clst;
            //dataGridView1.DataSource = qry;
        }
示例#9
0
        private void btnEx11_Click(object sender, EventArgs e)
        {
            DafestyEntities context = new DafestyEntities();
            //var qry = from x in context.Movies where x.VideoCode == 5 select new { x.MovieTitle,x.Rating,x.Producer.ProducerName};
            var qry = context.Movies.Where(x => x.VideoCode == 5).Select(x => new { x.MovieTitle, x.Rating, x.Producer.ProducerName });

            //lblEx7Ans.Text = qry;
            //lblEx7Ans.Visible = true;
            dataGridView1.DataSource = qry.ToList();
        }
示例#10
0
        private void btnEx10_Click(object sender, EventArgs e)
        {
            DafestyEntities context = new DafestyEntities();
            //var qry = from x in context.Movies group x by x.MovieType into g select new { Category = g.Key, TotalStock = g.Sum(Y => Y.TotalStock) };
            var qry = context.Movies.GroupBy(x => x.MovieType).Select(g => new { Category = g.Key, TotalStock = g.Sum(Y => Y.TotalStock) });

            //lblEx7Ans.Text = qry;
            //lblEx7Ans.Visible = true;
            dataGridView1.DataSource = qry.ToList();
        }
示例#11
0
        private void btn9_Click(object sender, EventArgs e)
        {
            DafestyEntities context = new DafestyEntities();
            //var qry = from x in context.Movies where x.Rating == "R" select new { x.VideoCode, x.MovieTitle, x.RentalPrice};
            var qry = context.Movies.Where(x => x.Rating == "R").Select(o => new { o.VideoCode, o.MovieTitle, o.RentalPrice });

            //List<Movy> clst = qry.ToList<Movy>();
            dataGridView1.DataSource = qry.ToList();
            //dataGridView1.DataSource = qry;
        }