Пример #1
0
 public void Add(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         context.Products.Add(product);
         context.SaveChanges();
     }
 }
Пример #2
0
 public void Delete(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         var entity = context.Entry(product);
         entity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Пример #3
0
 public void Update(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         //context.Products.Add(product);
         var entity = context.Entry(product);
         entity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }