Linq选择很多属性x存在于externalList中的位置

asu*_*ppa 2 c# linq linq-to-objects linq-to-entities

我知道的措词不好,所以我会在这里说清楚..

我有

List<int> relevantIDs; //self explanitory
Run Code Online (Sandbox Code Playgroud)

现在我试图从数据库中选择一个对象列表,其中的ID存在于上面的列表中...我似乎无法弄清楚linq ...

dbContext.objs.where(x => x.id ....).toList();
//I cant figure out the .... i was thinking there was an "in" but got no where...
Run Code Online (Sandbox Code Playgroud)

有人可以指点我一篇文章,或者给我一个可以完成我需要的样本.该列表太大了,无法检索它们然后过滤掉....并且在这种情况下重复点击数据库将不是最佳的...

Gra*_*ICA 6

你想找到那些包含在数据库中的标识的"相关标识"的集合,所以这应该工作:

dbContext.objs.Where(x => relevantIDs.Contains(x.id)).ToList();
Run Code Online (Sandbox Code Playgroud)