3
我有一个精简版问题,我真的不知道如何解决。在我的示例下面,我想选择一个ProductItems列表ProductItems是活跃的。linq to entity - 包含lambda表达式
public IEnumerable<ProductCategory> ListProductCategories()
{
return _entities.ProductCategorySet.Include("ProductItems").Where(x => x.ProductItems.Active == true).ToList();
}
问题是我无法访问productItem属性在我的lambda表达式中激活,是什么问题?当我试图编写像上面那样的linq查询时,我认为总是错的吗?
解决方案并没有真正解决问题。您的解决方案仅返回包含任何产品项目的产品类别。无论他们是否活跃,都无关紧要。 我想要返回的是所有产品类别和产品项目,只有当产品项目处于活动状态时== true。 – Webking 2010-02-14 10:55:07
也许你想要所有而不是任何?我会更新我的答案。 – 2010-02-14 12:16:12