public static List <Employee> Get() { using (var ctx = new SampleDBContext()) { var e = from ent in ctx.Employee select ent; return(e.ToList()); } }
public static void AddEmployee(Employee employee) { using (var ctx = new SampleDBContext()) { ctx.Employee.Add(employee); ctx.SaveChanges(); } }
public static void AddDepartment(Department department) { using (var context = new SampleDBContext()) { //context.Department.Add(department); //context.SaveChanges(); } }
public static Employee EmployeeExist(Employee employee) { using (var ctx = new SampleDBContext()) { var id = from e in ctx.Employee where e.EmployeeName == employee.EmployeeName && e.Department == employee.Department select e; return(id.FirstOrDefault()); } }
public static Department DepartmentExist(Department department) { using (var ctx = new SampleDBContext()) { //var id = from d // in ctx.Department // where // d.Name == department.Name // select d; //return id.FirstOrDefault(); } return(new Department { Id = 1, Name = "HRD", IsActive = true }); }