示例#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();
     }
 }