Linq query with Array in where clause?

前端 未结 4 991
无人共我
无人共我 2020-12-28 16:23

I have searched for this, but still can\'t seem to get this to work for me. I have an array of Id\'s associated with a user (their Organization Id). These are placed in an

4条回答
  •  爱一瞬间的悲伤
    2020-12-28 17:15

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

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

    This will translate into SQL something like..

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

提交回复
热议问题