如何在 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
}