/// <summary> /// This method will add Student data into database... /// </summary> public void AddStudentData(Student stentity) { using (var context = new TestDbEntities1()) { context.Students.Add(stentity); context.SaveChanges(); } }
/// <summary> /// This method will add Employee data into database... /// </summary> public void AddEmployeeData(Employee emp) { using (var context = new TestDbEntities1()) { context.Employees.Add(emp); context.SaveChanges(); } }
/// <summary> /// This method will delete Student data into database... /// </summary> /// <param name="Id"></param> public void deleteStudent(int Id) { stentity.Studentid = Id; TestDbEntities1 context = new TestDbEntities1(); var dto = (from d in context.Students where d.Studentid == Id select d).Single(); context.Students.Remove(dto); context.SaveChanges(); }
/// <summary> /// This method will delete Employee data into database... /// </summary> /// <param name="Id"></param> public void deleteEmployee(int Id) { emp.Employeid = Id; TestDbEntities1 context = new TestDbEntities1(); var dto = (from d in context.Employees where d.Employeid == Id select d).Single(); context.Employees.Remove(dto); context.SaveChanges(); }
/// <summary> /// This method will update Student data into database... /// </summary> /// <param name="Id"></param> public void UpdateStudent(Student stentity, int Id) { stentity.Studentid = Id; TestDbEntities1 context = new TestDbEntities1(); var student = (from d in context.Students where d.Studentid == Id select d).Single(); student.State = stentity.State; student.Country = stentity.Country; context.SaveChanges(); }
/// <summary> /// This method will update Employee data into database... /// </summary> /// <param name="Id"></param> public void UpdateEmployee(Employee emp, int Id) { emp.Employeid = Id; TestDbEntities1 context = new TestDbEntities1(); var student = (from d in context.Employees where d.Employeid == emp.Employeid select d).Single(); student.State = emp.State; student.Country = emp.Country; context.SaveChanges(); }