public void DeleteEmployee2(int empid) { using (DbContextClass1 context = new DbContextClass1()) { var emp2 = context.Eemployee2.Where(d => d.EmpId == empid).FirstOrDefault(); if (emp2 != null) { context.Eemployee2.Remove(emp2); context.SaveChanges(); } } }
public void AddEmployee2(string departmentName) { using (DbContextClass1 context = new DbContextClass1()) { Employe2 emp2 = new Employe2() { department = departmentName }; context.Eemployee2.Add(emp2); context.SaveChanges(); } }
public void UpdatEMployee2(int empid, string department) { using (DbContextClass1 context = new DbContextClass1()) { var emp2 = context.Eemployee2.Where(d => d.EmpId == empid).FirstOrDefault(); if (emp2 != null) { emp2.department = department; context.Entry(emp2).State = Microsoft.EntityFrameworkCore.EntityState.Modified; context.SaveChanges(); } } }