EF6 按条件更新多行记录的值

using (var db = new MyDbContext())
{
  string fromUser = ""; //sender
  string toUser = ""; //receiver
  var messages = db.Message.Where(x => x.FromUser == fromUser && x.ToUser == toUser)
                 .ToList();
  messages.ForEach(m => m.IsRead = true);
  db.SaveChanges();
}
posted on 2017-08-13 15:15  hahahoo  阅读(2182)  评论(0编辑  收藏  举报