I was trying to display the result without model(CLASS),i already have a department and Employee class ,now to show their joined result I don,t want to make another class which contains EmpName and Department Name property
IN MODEL
public class EmpDetails
{
public int EmpID { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public int DepartmentID { get; set; }
}
public class Department
{
public int DepartmentID { get; set; }
public string DepartmentName { get; set; }
public string Location { get; set; }
}
In Controller
var q = (from ED in cc.EmpDetails
join DT in cc.Department
on ED.DepartmentID equals DT.DepartmentID
select new {
ED.Name,
DT.DepartmentName
});
ViewBag.ListData = q;
In View
foreach (var item in ViewBag.ListData)
{
<div>
@item.Name
</div>
<div>
@item.DepartmentName
</div>
}
I want it to be done without using model
What I have tried:
I tried by making a new model for empName and department name which was succesfull,
but i want to do it without model class