I am getting result from theee tables usign linq to sql but i am unable to use the values in the view, how i can do that as i am new to mvc
here is my controller code:
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);
}
and I am doing like this in view:
@foreach(var item in ViewBag.Result)
{
<h1>@item</h1>
}
using
clause. – asawyer 9 hours ago