且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在where子句中使用数组进行LINQ查询?

更新时间:2022-11-21 19:19:24

虽然这可能更适合联接,但是您可以使用以下方法:

While this is probably better suited to a join, you can use this:

List<Personnel> query = 
    (from p in this.Database.Personnels 
    where OrgIds.Contains(p.OrgID) select p).ToList();

这将转换为类似SQL的内容.

This will translate into SQL something like..

where OrgID in (1,2,...,n)