Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        public ActionResult Index2()
        {
            sampleDBContextStudents db = new sampleDBContextStudents();

            return(View(db.Students));
        }