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)); }
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)); }
public IActionResult Index() { return(View(_sc.ReadAllStudents())); }