Beispiel #1
0
 public static List <Employee> Get()
 {
     using (var ctx = new SampleDBContext())
     {
         var e = from ent in ctx.Employee select ent;
         return(e.ToList());
     }
 }
Beispiel #2
0
 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();
     }
 }
Beispiel #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());
     }
 }
 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
     });
 }