public void addProduct(product p) { using (var ctx = new ProductsContext()) { ctx.Products.Add(p); ctx.SaveChanges(); } }
public product getProduct(long ID) { product Product; using (var ctx = new ProductsContext()) { Product = ctx.Products.FirstOrDefault(p => p.productID == ID); } return(Product); }
public System.Collections.IEnumerable getProducts() { List <product> products = new List <product>(); using (var ctx = new ProductsContext()) { products = ctx.Products.ToList(); } return(products); }
public void updateProduct(product newProduct) { product Product; using (var ctx = new ProductsContext()) { Product = ctx.Products.FirstOrDefault(p => p.productID == newProduct.productID); Product.DeepCopy(newProduct); ctx.SaveChanges(); } }