Пример #1
0
 public void CreateCustomer(Customer customer)
 {
     using (var db = new OskarEntities())
     {
         db.Customers.Add(customer);
         db.SaveChanges();
     }
 }
Пример #2
0
 public void UpdateCustomer(Customer customer)
 {
     using (var db = new OskarEntities())
     {
         db.Customers.Attach(customer);
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Пример #3
0
 public void DeleteCustomer(int customerId)
 {
     using (var db = new OskarEntities())
     {
         var customer = new Customer { CustomerId = customerId };
         db.Customers.Attach(customer);
         db.Customers.Remove(customer);
         db.SaveChanges();
     }
 }