public JsonResult GetStudents(string term) { sampleDBContextStudents db = new sampleDBContextStudents(); List <string> students = db.Students.Where(s => s.Name.StartsWith(term)) .Select(x => x.Name).ToList(); return(Json(students, JsonRequestBehavior.AllowGet)); }
public ActionResult Index2(string searchTerm) { sampleDBContextStudents db = new sampleDBContextStudents(); List <Student> students; if (string.IsNullOrEmpty(searchTerm)) { students = db.Students.ToList(); } else { students = db.Students .Where(s => s.Name.StartsWith(searchTerm)).ToList(); } return(View(students)); }
public ActionResult Index2() { sampleDBContextStudents db = new sampleDBContextStudents(); return(View(db.Students)); }