internal EmployeeListViewModel GetViewModel_Internal() { var employeeQuery = new EmployeeQuery(ModelContext); // get employees (w/o references, sorted) var sortedEmployees = employeeQuery.ListByDivisionId(Settings.DivisionID, Settings.IncludeSubdivisions, Settings.SortType).ToList(); // get employees (with references, unsorted) var filledEmployees = employeeQuery.ListByIds(sortedEmployees.Select(se => se.EmployeeID)); // update sorted employees list for (var i = 0; i < sortedEmployees.Count; i++) { sortedEmployees [i] = filledEmployees.Single(fe => fe.EmployeeID == sortedEmployees [i].EmployeeID); } return(new EmployeeListViewModel( sortedEmployees, ModelContext.Get <DivisionInfo> (Settings.DivisionID) )); }