Reputation: 3
How can I convert the following SQL
statement to linQ
?
select * from student where student_id in (4 , 10 , 20 , 50)
I've tried the following but it doesn't work:
var SelectedStudent = db.Students
.Include(i => i.grade)
.Where(i => i.studentID in (1,2,3))
.ToList();
Upvotes: 0
Views: 32
Reputation: 31
var collIds={10,20,30,40};
var results=(from s in dbo.Student
join c in collIds
on s.id equals c
select s).ToList();
Upvotes: 0
Reputation: 172646
var ids = new [] { 1,2,3};
var students =
from student in db.Students
where ids.Contains (student.StudentId)
select student;
Upvotes: 1