Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class OfficeDTO
- {
- public IEnumerable<EmployeeDTO> Employees { get; set; }
- public IEnumerable<DepartmentDTO> Departments { get; set; }
- }
- public class EmployeeDTO
- {
- public int EmpId { get; set; }
- public string EmpName { get; set; }
- }
- public class DepartmentDTO
- {
- public string DeptCode { get; set; }
- public string DeptName { get; set; }
- }
- public ActionResult Index()
- {
- EF.OfficeEntities ctx = new EF.OfficeEntities();
- Models.OfficeDTO office = new Models.OfficeDTO();
- using (ctx)
- {
- var empList = ctx.GetEmployeesByYearJoined("2009")
- .ToList();
- var empResults = (from q in empList
- select new Models.EmployeeDTO
- {
- EmpId = q.EmpID,
- EmpName = q.FirstName + q.LastName
- }).ToList();
- office.Employees = empResults;
- var depResults = (from q in ctx.Departments
- select new Models.DepartmentDTO
- {
- DeptCode = q.DepartmentCode,
- DeptName = q.DepartmentName
- }).ToList();
- office.Departments = depResults;
- }
- return View(office);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement