日期:2014-05-17 浏览次数:20572 次
public ActionResult Demo() { NorthwindEntity entity = new NorthwindEntity(); IQueryable<Products> pro = from s in entity.Products where s.ProductID == 1 select s; return View(pro); } //为什么用这个方法不能更新实体类库里的Products数据呢,请问哪里出错啊,请大牛帮忙,谢谢! public ActionResult UpdateDemo(Products pd) { NorthwindEntity entity = new NorthwindEntity(); Products model = entity.Products.FirstOrDefault(e => e.ProductID == pd.ProductID); UpdateModel(model, pd.ProductName); entity.SaveChanges(); return RedirectToAction("Demo"); }