控制器
[HttpPost]
public ActionResult EditUserProfile(UserProfiles _postedUserProfile)
{
UserProfiles orjinalUserProfile = entity.UserProfiles.Where(x => x.UserId == _postedUserProfile.UserId).Single();
orjinalUserProfile.AboutMe = _postedUserProfile.AboutMe;
orjinalUserProfile.Birthday = _postedUserProfile.Birthday;
orjinalUserProfile.Comments = _postedUserProfile.Comments;
...... // there are lines more
entity.SaveChanges();
return View();
}
我像上面一样更新了实体。但我认为这种方式并不好。是否有任何解决方案来更新一行中的实体,例如像entity.AddToUserProfiles
.
谢谢。