2010-09-03 12 views
19
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> 

Wie wähle ich Werte aus, wo die d.periods im periods-Array enthalten sind?Linq Wo der Wert in Array ist

Antwort

32

Verwenden Sie die Contains Methode.

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