Reputation: 25
I want to write linq statement for this sql statement below:
select * from Table1 where Table1.Id in (1, 2, 3, 4)
I have selection set in a array or list
What is the linq statement?
Upvotes: 0
Views: 122
Reputation: 101681
var IdList = new List<int>() { 1,2,3,4 };
var result = db.Table.Where(x => IdList.Contains(x.Id)).ToList();
Edit: According to your comment:
db.tPass.Where(p => p.date == DateTime.Now
&& IdList.Contains(Convert.ToInt32(p.Id)).ToList();
Upvotes: 4