public ActionResult EditRow()
{
using (SchoolContext db = new SchoolContext())
{
var v = db.Students.ToList();
return View(v);
}
}
[HttpPost]
public ActionResult EditRow(List<Student> student)
{
if (ModelState.IsValid)
{
using (SchoolContext db = new SchoolContext())
{
foreach (var i in student)
{
var c = db.Students.Where(a => a.ID.Equals(i.ID)).FirstOrDefault();
if (c != null)
{
c.LastName = i.LastName;
c.FirstMidName = i.FirstMidName;
c.EnrollmentDate = i.EnrollmentDate;
}
}
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.Message = "Successfully updated";
return View(student);
}
else
{
ViewBag.Message = "failed";
return View(student);
}
Right now I have implemented this code,but server takes more time to edit records. Is there any way to edit records quickly? How can I minimise Execution time? and how to check time complexity in Visual studio?