See below implementation how to pass multiple result set to View page from Controller:
Controller
public ActionResult Index()
{
LMSViewModel Container = new LMSViewModel();
var DepteData = (from D in Db.Departments
select new
{
Name=D.DepartmentName,
Budget=D.DepartmentBudget,
Building=D.BuildingName
}).ToList();
Container.Students =DepteData;
return View(Container);
}
In Controller we assign only Students object - you need to assign other objects like departments, teachers. So that you can access those property in view page.
View
@model MultipleModelDemo.ViewModel.LMSViewModel
@foreach (var item in Model.Students)
{
<div>@item.PropertyName</div>
}
@foreach (var item in Model.Departments)
{
<div>@item.PropertyName</div>
}
In view page, you need to change property names and ViewModel reference as per your need.
Moreover please visit
Multiple Models in a View in ASP.NET MVC 4 / MVC 5[
^]