コード例 #1
0
        public Product GetProduct(int Id)
        {
            var product = _commerceDbContext.Product.Find(Id);

            _commerceDbContext.Entry(product).Reference(p => p.Category).Load();
            _commerceDbContext.Entry(product).Collection(p => p.ProductImages).Load();
            return(product);
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "ProductID,Name,Price")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }