2011-04-11 85 views

回答

6

首先聲明你的 「在」 值集合中的變量:

var collection = new[] { "value1","value2","value3" }; 

然後在查詢中使用它:

... 
where collection.Contains(item.field) 
... 
1

或者在lambda語法(比如你有一個你正在搜索的集合):

var lookup = new[] { "value1","value2","value3" }; 
var result = collection.Where(x=> lookup.Contains(x)).ToArray();