我正在查詢一個數據表使用LINQ,然後查詢結果來篩選出我想要的,問題是我需要查詢它的每個數組的值這些值是這樣的, 2,或22,或21等添加結果到LINQ查詢
所以我通常做這個
results = from a in results
where a.countryId.ToString().Contains(value)
select a;
我想這樣做,這是什麼
foreach(string str in arrayval)
{
results += from a in results
where a.countryId.ToString().Contains(str)
}
誰能幫助或者給我一些線索
謝謝
你在循環中沒有對你的'str'值做任何事情?這個循環的目的是什麼? –
你有沒有試過,並得到一個錯誤? 你沒有在你的foreach循環中使用'str'或'arrayval'。 – Amicable