Complex orderby question (entity framework)

Posted by PFranchise on Stack Overflow See other posts from Stack Overflow or by PFranchise
Published on 2010-06-10T04:31:19Z Indexed on 2010/06/10 4:32 UTC
Read the original article Hit count: 201

Filed under:
|
|
|

Ok, so I will start by saying that I am new to all this stuff, and doing my best to work on this project. I have an employee object, that contains a supervisor field. When someone enters a search on my page, a datagrid displays employees whose name match the search. But, I need it to display all employees that report to them and a third tier of employees that report to the original employee's underlings. I only need three tiers. To make this easier, employees only come in 3 ranks, so if rank==3, that employee is not in charge of others. I imagine the best method of retrieving all these employees from my employee table would be something like

from employee in context.employees
where employee.name == search || employee.boss.name == search || 
employee.boss.boss.name == search

But I am not sure how to make the orderby appear the way I want to. I need it to display in tiers. So, it will look like: Big Boss Boss underling underling Boss underling Boss Boss Big Boss

Like I said, there might be an easier way to approach this whole issue, and if there is, I am all ears. Any advice you can give would be HIGHLY appreciated.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET