C#:LINQ中的IN子句
时间:2021-05-06 09:35:11
收藏:0
阅读:18
如何使where in子句类似于SQL Server中的in子句?
1 var results = from states in _objectdatasource.StateList() 2 where listofcountrycodes.Contains(states.CountryCode) 3 select new State 4 { 5 StateName = states.StateName 6 }; 7 // OR 8 var results = _objectdatasource.StateList() 9 .Where(s => listofcountrycodes.Contains(s.CountryCode)) 10 .Select(s => new State { StateName = s.StateName});
原文:https://www.cnblogs.com/IIXS/p/14733509.html
评论(0)