Пример #1
0
 public int Upsert(Employee employee)
 {
     using (var context = new CodeFirstModels())
     {
         if (employee.EmployeeKey == 0)
         {
             context.Entry(employee).State = EntityState.Added;
         }
         else
         {
             context.Entry(employee).State = EntityState.Modified;
         }
         context.SaveChanges();
         return(employee.EmployeeKey);
     }
 }
Пример #2
0
 public void Update(Employee employee)
 {
     using (var context = new CodeFirstModels())
     {
         context.Entry(employee).State = EntityState.Modified;
         context.SaveChanges();
     }
 }