TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
kls dngr
NA
17
5.4k
How to display two class result using LINQ to view in MVC?
Aug 6 2015 5:59 AM
Here is my controller action method code but I don't have any idea to display that result to view?
public class DetailsController : Controller
{
//
// GET: /Details/
List<Employee> employees = new List<Employee>();
List<Department> departments = new List<Department>();
public ActionResult Index()
{
employees.Add(new Employee { DepartmentID = 1, EmployeeID = 1, EmployeeName = "Kailas" });
employees.Add(new Employee { DepartmentID = 2, EmployeeID = 2, EmployeeName = "Dipak" });
employees.Add(new Employee { DepartmentID = 2, EmployeeID = 3, EmployeeName = "Pramod" });
employees.Add(new Employee { DepartmentID = 1, EmployeeID = 4, EmployeeName = "Prakash" });
employees.Add(new Employee { DepartmentID = 3, EmployeeID = 5, EmployeeName = "Pranav" });
employees.Add(new Employee { DepartmentID = 4, EmployeeID = 6, EmployeeName = "Dipesh" });
departments.Add(new Department { DepartmentID = 1, DepartmentName = "IT" });
departments.Add(new Department { DepartmentID = 1, DepartmentName = "BA" });
departments.Add(new Department { DepartmentID = 1, DepartmentName = "CS" });
departments.Add(new Department { DepartmentID = 1, DepartmentName = "MBA" });
departments.Add(new Department { DepartmentID = 1, DepartmentName = "Comm" });
var list = (from e in employees
join d in departments
on e.DepartmentID equals d.DepartmentID
select new {
EmployeeName = e.EmployeeName,
DepartmentName = d.DepartmentName
}).ToList();
return View(list);
}
}
Reply
Answers (
3
)
How to create Nification in Asp.net Mvc 5 code first
How to refresh a webgrid based on a value inside a webgrid?