예제 #1
0
 public static List <Employee> Get()
 {
     using (var ctx = new SampleDBContext())
     {
         var e = from ent in ctx.Employee select ent;
         return(e.ToList());
     }
 }
예제 #2
0
 public static void AddEmployee(Employee employee)
 {
     using (var ctx = new SampleDBContext())
     {
         ctx.Employee.Add(employee);
         ctx.SaveChanges();
     }
 }
예제 #3
0
 public static void AddDepartment(Department department)
 {
     using (var context = new SampleDBContext())
     {
         //context.Department.Add(department);
         //context.SaveChanges();
     }
 }
예제 #4
0
 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());
     }
 }
예제 #5
0
 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
     });
 }