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?
LINQ is a Microsoft technology to perform operations on nearly all data sources. Here I have described nearly all data sources. Yes it supports General Arrays, Generic Lists, XML, Databases and even flat files.
LINQ Contains operator is used to check whether an element is available in sequence (collection) or not. Contains operator comes under Quantifier Operators category in LINQ Query Operators. Below is the syntax of Contains operator.
Contains() is a string method. This method is used to check whether the substring occurs within a given string or not. It returns the boolean value. If substring exists in string or value is the empty string (“”), then it returns True, otherwise returns False.
Use the Contains method.
var someData = from p in returns from d in p.ReturnDet where p.Year > 2009 where periods.Contains(d.Period);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With