コード例 #1
0
        public void Update(Ratings rating)
        {
            var ratingInDb = db.Ratings.Find(rating.RatingID);

            if (ratingInDb == null)
            {
                return;
            }

            db.Entry(ratingInDb).CurrentValues.SetValues(rating);
            db.Entry(ratingInDb).State = EntityState.Modified;
            db.SaveChanges();
        }
コード例 #2
0
        public void Update(T item, Func <T, bool> findByIDPredecate)
        {
            var local = Context.Set <T>()
                        .Local
                        .FirstOrDefault(findByIDPredecate);

            if (local != null)
            {
                Context.Entry(local).State = EntityState.Detached;
            }
            Context.Entry(item).State = EntityState.Modified;
            Context.SaveChanges();
        }
コード例 #3
0
        public void Update(T entity)
        {
            var entry = db.Entry(entity);

            entry.State = EntityState.Modified;
            db.SaveChanges();
        }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "Id,Name,Description,Ingredients,Directions,Source,Category,Image_URL")] Recipe recipe)
 {
     if (ModelState.IsValid)
     {
         db.Entry(recipe).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(recipe));
 }