我有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).
我已經刪除以前使用的順序,但仍然面臨同樣的問題出來是在排序的形式。 –