コード例 #1
0
ファイル: StudentController.cs プロジェクト: JohnCaveson/.NET
        public IActionResult FirstNamesContainingA()
        {
            var students = _sc.ReadAllStudents();
            //Extension Method
            //var query = students.Where(s => s.FirstName.Contains("a"));
            //Query Syntax
            var query = from s in students
                        where s.FirstName.Contains("a")
                        select s;
            var model = query.ToList();

            return(View(model));
        }
コード例 #2
0
        public IActionResult StudentsWithGradeA()
        {
            var students = _repo.ReadAllStudents();

            ViewData["Title"] = "Students With Grade A";

            /*
             * Query syntax
             * var query = from s in students
             *          where s.Grades.Any(sg => sg.LetterGrade == "A")
             *          select s;
             */
            var query = students.Where(s => s.Grades.Any(sg => sg.LetterGrade == "A"));
            var model = query.ToList();

            return(View(model));
        }
コード例 #3
0
 public IActionResult Index()
 {
     return(View(_sc.ReadAllStudents()));
 }