コード例 #1
0
 public void Delete(int id)
 {
     using (var Context = new OnlineShoppingSampleEntities())
     {
         try
         {
             var q = Context.Product.Find(id);
             Context.Product.Remove(q);
         }
         catch (Exception)
         {
             throw;
         }
         if (Context != null)
         {
             Context.Dispose();
         }
     }
 }
コード例 #2
0
 public void Update(Product product)
 {
     using (var Context = new OnlineShoppingSampleEntities())
     {
         try
         {
             var q = Context.Product.Find(product.Productid);
             q = product;
             Context.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
         if (Context != null)
         {
             Context.Dispose();
         }
     }
 }
コード例 #3
0
 public List <Product> Select()
 {
     using (var Context = new OnlineShoppingSampleEntities())
     {
         try
         {
             var q = Context.Product.ToList();
             return(q);
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             if (Context != null)
             {
                 Context.Dispose();
             }
         }
     }
 }
コード例 #4
0
 public void Insert(Product product)
 {
     using (var Context = new OnlineShoppingSampleEntities())
     {
         try
         {
             Context.Product.Add(product);
             Context.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             if (Context != null)
             {
                 Context.Dispose();
             }
         }
     }
 }