0
我有一個列表,其中包含數字(5,9,3)。讓我們把它MYLIST使用LINQ查詢實現'屬於'
我想執行
var results = from a in myEntities.thing1 where a.ID belongsto MyList select a;
現在我做
List<T> t = new List<T>(); //I actually define T to a strong type
foreach (int i in MyList)
{
t.add(from a in myEntities.thing1 where a.ID==i select a);
}
我敢肯定,必須有一個更好的辦法,但我不能完全纏上了我圍着它轉。
我很笨............. – Matt 2009-11-18 01:52:52
LINQ2SQL有一個技巧,「MyList」必須是強類型引用「List <>」或「陣」。 如果你傳遞一個「IList」,linq2sql將無法編譯 – 2009-11-18 01:58:41