我有 3 个表: Product、Category和,和之间的多对多关系的连接表ProductCategory在哪里。以下 Linq 查询(它是类中的扩展方法)会导致当前. 为什么是这样?如何改进?另请注意,这是数据库优先的 EF。ProductCategoryProductCategoryCategoryProductCategoryCategory
public IEnumerable<Product> ActiveProducts
{
get
{
return this.ProductCategories.Where(c => !c.Product.IsDeleted && c.Product.IsActive).OrderBy(c => c.SortOrder).Select(c => c.Product);
}
}