コード例 #1
0
        public void Delete(Product product)
        {
            using (ETradeContext contex = new ETradeContext())
            {
                var entity = contex.Entry(product);
                entity.State = EntityState.Deleted;

                contex.SaveChanges();
            }
        }
コード例 #2
0
 public void Add(Product product)
 {
     using (ETradeContext contex = new ETradeContext())
     {
         var entity = contex.Entry(product);
         entity.State = EntityState.Added;
         // contex.Products.Add(product);
         contex.SaveChanges();
     }
 }