我开发一个ASP.NET MVC 4应用程序,我想在实体框架5无法隐式转换类型System.Collections.Generic.IEnumerable <>为bool
var customer = db.GNL_Customer.Where(d => d.GNL_City.FKProvinceID == advancedProvinceID || advancedProvinceID == null)
.Where(d => d.FKCityID == advancedCityID || advancedCityID == null)
.Where(d => d.FKDepartmentStoreID == advancedDepartmentStoreID || advancedDepartmentStoreID == null)
.Where(d => d.GNL_CustomerLaptopProduct.Where(r => String.Compare(r.BrandName, brandID) == 0 || brandID == null));
运行这个Lambda表达式
我得到这个错误:
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<ITKaranDomain.GNL_CustomerLaptopProduct>' to 'bool'
我知道,最后的where子句是错误的,但我不知道如何纠正它。
正如Andrew在他的回答中指出的那样,您需要使用'Any'作为'Where where will return an'IEnumerable''而Any'的谓词需要一个'bool'返回函数ñ。 –