Beispiel #1
0
 public void CreateProduct(Product product)
 {
     using (var db = new OskarEntities())
     {
         db.Products.Add(product);
         db.SaveChanges();
     }
 }
Beispiel #2
0
 public void UpdateProduct(Product product)
 {
     using (var db = new OskarEntities())
     {
         db.Products.Attach(product);
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Beispiel #3
0
 public void DeleteProduct(int productId)
 {
     using (var db = new OskarEntities())
     {
         var product = new Product { ProductId = productId };
         db.Products.Attach(product);
         db.Products.Remove(product);
         db.SaveChanges();
     }
 }