我正在从使用 linq 到 sql 的 theee 表中获取结果,但我无法使用视图中的值,我如何做到这一点,因为我是 mvc 的新手
这是我的控制器代码:
public ActionResult Grid()
{
ViewBag.Message = "Your Grid page.";
bc_limsEntities objbc_limsDBContext = new bc_limsEntities();
var result = from b in objbc_limsDBContext.dc_tpatient_bookingm
join d in objbc_limsDBContext.dc_tpatient_bookingd on b.bookingid equals d.bookingid
join t in objbc_limsDBContext.dc_tp_test on d.testid equals t.TestId
where b.bookingid == 41239 && d.ProcessID == 0006 && t.SubdepartmentId == 16
select new {b.bookingid,
d.bookingdid,
d.testid,
t.Test_Name,
t.procedureid,
t.ClinicalUse,
t.AutomatedText};
ViewBag.Result = result.ToList();
return View(result);
}
我这样做是因为:
@foreach(var item in ViewBag.Result)
{
<h1>@item</h1>
}