1

在 sql 我有查询

select * from table where id in (5,7,8)

如何在 LINQ 查询中执行此操作?

4

2 回答 2

6
var t = from u in table
               where new[] { 5, 7, 8 }.Contains(u.id)
               select u
于 2012-04-18T09:08:50.447 回答
3
var ids = new int[] { 5, 7, 8 };
var rows = from row in table 
           where ids.Contains(row.id) 
           select row
于 2012-04-18T09:11:42.717 回答