如何在mvc4視圖中顯示數據庫上下文數據?下面是我的控制器代碼:如何在從控制器返回的mvc4視圖中顯示數據庫上下文數據
public ActionResult Detail(int id)
{
AuthorContext oauthorContext = new AuthorContext();
Author oauthor = oauthorContext.Authors.Single(x => x.authorid == id);
return View(oauthor);
}
,並考慮:
@{
ViewBag.Title = "Author Detail";
}
<h2>AuthorDetail</h2>
@{
foreach Context in
}
,我沒有得到對象oauthorcontext @ {的foreach上下文中} – user2654740