linq to sql を使用する theee テーブルから結果を取得していますが、ビューで値を使用できません。
ここに私のコントローラコードがあります:
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>
}