public void UpdateStudent(StudentData student) { using (SchoolDB db = new SchoolDB()) { var EditedObj = db.Student.Find(student.ID); if (EditedObj != null)//if student is found { EditedObj.StudentName = student.Name; db.SaveChanges(); } } }
public StudentData GetStudent(int StudentID) { var student = new StudentData(); using (SchoolDB db = new SchoolDB()) { var studentDB = db.Student.Find(StudentID); student.ID = studentDB.StudentID; student.Name = studentDB.StudentName; } return(student); }