我有一个类别列表(CategoryID's) List categoryIds; 此列表包含一些基于用户先前选择的 id。
然后我有一个数据库,其中包含可以成为一个或多个类别成员的公司。这是在连接表 CompaniesInCategory 中维护的,这会产生像 company.Categories 这样的对象结构。
现在我的问题是,我如何选择至少属于所选类别之一的所有公司。
List<int> categoryIds = new List<int>() {123, 3, 5858, 23};
List<company> companies = (from c in context.Companies
where c.Categories.(one of the Id's of these c.Categories should be in the list named categoryIds)
select c);
每个公司都有一个附加的类别列表。从这个类别列表(c.Categories)(它们都有一个 CategoryId)中,至少有一个必须与列表 categoryIds 中的一个 id 匹配。