我有一個如下所示的查詢。任何人都知道爲什麼?:部件總是返回錯誤的值,儘管在LIST中有項目包含。或者任何人有更好的想法寫這個查詢,請隨時在這裏回覆。謝謝。LinQ:?:選擇查詢中的運算符
List EList = new List();
EList.Add(new EmployeeInfo(1, "a1", "b1"));
EList.Add(new EmployeeInfo(2, "a2", "b2"));
List OList = new List();
OList.Add(new EmployeeInfo(1, "a1", "b1"));
OList.Add(new EmployeeInfo(2, "a2", "b2"));
OList.Add(new EmployeeInfo(3, "aa2", "bb2"));
var results = (
from e in b
select new
{
Id = e.ID,
Name = e.Name,
Email = e.Email,
IS_Elist = (EList.Contains(e))?true:false,
IS_Olist = (OList.Contains(e)) ? true : false,
}
).ToList();
等等,什麼? '?true:false'是完全多餘的。只要說'IS_Elist = Elist.Contains(e),IS_Olist = Olist.Contains(e)'。 –
'b'從哪裏來? –