我的 Web 应用程序中有一个 linq to sql 查询。我刚刚意识到它是根据员工编号对结果进行升序排序。有没有办法让它按照提供的顺序返回结果?
我的代码如下:
public static queryClass[] GetEmpData(int empID1, int empID2, int empID3, int empID4, int empID5, int empID6, int empID7, int empID8, int empID9, int empID10)
{
using(var context = new EmpInfoDataContext())
{
var query = from e in context.EmployeeMasters
join j in context.JobClasses on e.JobClass equals j.JobClass
where e.EmployeeNo == empID1 || e.EmployeeNo == empID2 || e.EmployeeNo == empID3 || e.EmployeeNo == empID4 || e.EmployeeNo == empID5 || e.EmployeeNo == empID6 || e.EmployeeNo == empID7 || e.EmployeeNo == empID8 || e.EmployeeNo == empID9 || e.EmployeeNo == empID10
select new queryClass{firstName = e.FirsName, lastName = e.LastName, employeeNo = e.EmployeeNo, department = j.Department};
return query.ToArray();
}
}
提前致谢。