Easy way to write WHERE IN clause in Linq
I found many links to write IN clause in Linq but following is the simplest way achieve this
public IEnumerable<Products> GetProductsByIds(List<int > ids)
{
from id in Products
where (x => ids.Contains(x.Id))
select new {x.Id, x.ProductName};
}
var productids = new List<int> { 33,34,35,36 };
GetProductsByIds(productids);
Happy Coding..!
Suresh Behera