public void findEmployees(Employee e) { using (var context = new TestDataBaseEntities()) { List <Employee> eList = (from employee in context.Employees where employee.empName == e.empName select employee).ToList <Employee>(); //var tet = from emp in context.Employees select emp; } }
public List <Employee> getEmployees() { using (var context = new TestDataBaseEntities()) { var eList = context.Employees.ToList <Employee>(); return(eList); } }
public void addEmployee(Employee employee) { using (var context = new TestDataBaseEntities()) { var eList = context.Employees.ToList <Employee>(); context.Employees.Add(employee); context.SaveChanges(); } }
public void displayEmployees() { using (var context = new TestDataBaseEntities()) { var eList = context.Employees.ToList <Employee>(); foreach (var employee in eList) { System.Console.WriteLine(employee.empNo + "\t" + employee.empName + "\t" + employee.dsgn); } } }
public void deleteEmployee(Employee employee) { using (var context = new TestDataBaseEntities()) { var emp = context.Employees.Find(employee.empNo); if (emp == null) { System.Console.WriteLine("Object not found."); } else { System.Console.WriteLine(emp.empName); context.Employees.Remove(emp); context.SaveChanges(); } } }
public void updateEmployee(Employee employee) { using (var context = new TestDataBaseEntities()) { var emp = context.Employees.Find(employee.empNo); if (emp != null) { emp.empName = employee.empName; emp.salary = employee.salary; emp.mgrEmpNo = employee.mgrEmpNo; emp.dob = employee.dob; emp.doj = employee.doj; emp.dptCode = employee.dptCode; context.SaveChanges(); } else { System.Console.WriteLine("No such employee found."); } } }