开发者

Linq Where value is in Array

开发者 https://www.devze.com 2023-01-14 03:21 出处:网络
IEnumerable<string> periods 开发者_高级运维= new string[] {\"ABC\", \"JKD\", \"223A\"}; var someData = from p in returns
IEnumerable<string> periods 开发者_高级运维= new string[] {"ABC", "JKD", "223A"};

var someData = from p in returns  
               from d in p.ReturnDet  
               where p.Year > 2009 
               where d.Period <is in periods array> 

How do I select values where the d.periods are contained in the periods array?


Use the Contains method.

var someData = from p in returns   
               from d in p.ReturnDet   
               where p.Year > 2009  
               where periods.Contains(d.Period);


var someData = from p in returns  
      from d in p.ReturnDet  
                where p.Year > 2009 
                where periods.Contains(d.Period)
0

精彩评论

暂无评论...
验证码 换一张
取 消