我有integers ids
列表,从表中我只需要为那些ID在列表中,I have already done that
选择的细节,但我需要一个data sorted same way as they were in the list Explaination below:
在LINQ C#从数据库中选择数据后如何获得通过编号的顺序排列输出
List<int> SelectedUser = new List<int> { 26,1,22,27 };
List<ValidateDropDownBind> objValidateUserList = (from p in context.tblUser
join q in context.tblTaskReportingAuthority on p.UserID equals q.UserID into gj
from r in gj.DefaultIfEmpty()
where p.IsActive == true && p.CompanyID == CurrentAdminSession.CompanyID && SelectedUser.Contains(p.UserID)
//orderby r.TaskReportingAuthorityID
select new ValidateDropDownBind
{
value = p.UserID,
name = p.FirstName + " " + p.LastName
}).GroupBy(x => x.value, (key, group) => group.FirstOrDefault()).ToList();
,因为我运行此查询我得到的从数据库的详细信息列表中,但它是在sorted form but i need to sort them by the form which they were
在list (SelectedUser).
我已经删除以前使用的顺序,但仍然面临同样的问题出来是在排序的形式。 –