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