I have an object like this
public class Employee
{
public int EmployeeId { get; set; }
public string Name { get; set; }
public IList<Employee> Employees{ get; set; }
}
What I would like to do is select all of the employees, plus the parent employee in a single collection. I want to have the parent as the first item in the collection for paging. Right now I am doing something like this
Employee emp = getEmployeeFromService();
var allEmps = new List<Employee>();
allEmps.Add(emp);
allEmps.AddRange(emp.Employees);
var pagedEmployees= (from e in allEmps select e).Skip(offset).Take(pageSize);
Is there a better way to do this with a single linq statement?
Like this: