在sql中我有查询
select * from table where id in (5,7,8)
在LINQ查询中如何做到这一点?
答案 0 :(得分:6)
var t = from u in table
where new[] { 5, 7, 8 }.Contains(u.id)
select u
答案 1 :(得分:3)
var ids = new int[] { 5, 7, 8 };
var rows = from row in table
where ids.Contains(row.id)
select row