from adv in _context.Advisors
where adv.OfficeAdvisor.Any(off => off.OfficeId == officeID)
order adv by adv.OfficeAdvisor.First(off => off.OfficeId = officeID).Sequence
select adv;
David B
2008-09-30 20:38:46
from adv in _context.Advisors
where adv.OfficeAdvisor.Any(off => off.OfficeId == officeID)
order adv by adv.OfficeAdvisor.First(off => off.OfficeId = officeID).Sequence
select adv;
public static List<Advisor>GetOfficeEmployees(int OfficeID)
{
List<Advisor> lstAdvisors = null;
using (AdvisorDataModelDataContext _context = new AdvisorDataModelDataContext())
{
var advisors = from adv in _context.Advisors
join advisoroffice in _context.OfficeAdvisors
on adv.AdvisorId equals advisoroffice.AdvisorId
where advisoroffice.OfficeId == OfficeID
group adv by adv.OfficeId into g
order by g.Sequence
select g;
lstAdvisors = advisors.ToList();
}
return lstAdvisors;
}
Note: I am not able to currently test this on Visual Studio but should work.
You can add an order by clause like this:
var advisors = from adv in _context.Advisors
join advisoroffice in _context.OfficeAdvisors
on adv.AdvisorId equals advisoroffice.AdvisorId
where advisoroffice.OfficeId == OfficeID
orderby advisoroffice.Sequence // < -----
select adv;