我如何将以下SQL
语句转换为linQ
?
select * from student where student_id in (4 , 10 , 20 , 50)
我尝试了以下方法,但不起作用:
var SelectedStudent = db.Students
.Include(i => i.grade)
.Where(i => i.studentID in (1,2,3))
.ToList();
var ids = new [] { 1,2,3};
var students =
from student in db.Students
where ids.Contains (student.StudentId)
select student;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句