0
選擇。首先()的優先級,我有以下代碼:如何在一個特定集合
//Pretend there is a few static values in this list
List<string> repeatUserIds = new List<string>();
SomeCollection.Where(x => repeatUserIds.Contains(x.UserId)).First().MyCol = "somevalue";
MyEntities.SaveChanges(false);
scope.Complete();
MyEntities.AcceptAllChanges();
我也有一個List<string>
對象調用repeatUserIds
包含靜態用戶標識的,也許5個左右的列表。我希望能夠使我的SomeCollection.Where(x => repeatUserIds.Contains(x.UserId))
語句返回具有repeatUserIds
中012D中的舊用戶ID的項目,如果匹配項沒有匹配,如果repeatUserIds
(如果repeatUserIds.Contains retunrs爲false),則返回第一個項目SomeCollection。
首先使用'OrderBy'。就像在普通的SQL中一樣,結果集*必須被排序才能保證排序。 – 2012-10-08 22:28:05
'repeatUserIds'中的OLDEST是什麼意思? - 這個列表中的第一個條目是否匹配? –
對不起,我寫了可能讓你們很多人困惑的錯誤代碼,你能不能再給它一個回答? :) – anthonypliu