0
即时通讯设备试图让我的mvc应用程序中的控制器编辑数据模型中的特定实体,一旦用户点击编辑按钮,但是我似乎无法让它工作。我一直得到这个错误传入字典的模型项目的类型为'System.Data.Objects.ObjectQuery`1
传入字典的模型项目类型为'System.Data.Objects.ObjectQuery`1 [MvcApplication1.Models.New]',但是这个字典需要一个'MvcApplication1.Models'类型的模型项。新'。
我做错了什么。是由于强类型视图?
这里是我的控制器:
public ActionResult Edit(int id)
{
var productToEdit = from s in _entities.NewSet // return the story matching the clicked id
where s.storyId == id
select s;
return View(productToEdit);
}
// POST : Edit
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(New productToEdit)
{
try
{
var originalNews = (from s in _entities.NewSet
where s.storyId == productToEdit.storyId
select s).FirstOrDefault();
_entities.ApplyPropertyChanges(originalNews.EntityKey.EntitySetName, productToEdit);
_entities.SaveChanges();
return RedirectToAction("Index");
}
catch
{
return View();
}
}
能有人给我一些指点吧。我对这一切仍然陌生。
感谢Cybernate,已经工作了的魅力。您的传奇朋友 – mkkk 2011-01-14 21:25:24