在以下LINQ语句中,我收到错误:
无法将类型'System.Linq.IQueryable'隐式转换为'bool'
第3行最后一行在整行下面有一条蓝线。这是代码,我尝试了各种变化,我必须遗漏一些明显的东西,提前谢谢......
var allWaste = _securityRepository.FindAllWaste(userId, SystemType.W);
var searchResults = (
from s in allWaste
where
(
from x in _db.WasteIndicatorItems
join y in
_db.WasteIndicators
on x.WasteIndicatorId equals y.WasteIndicatorId
join z in
_db.HazardTypes
on y.HazardTypeId equals z.HazardTypeId
where
s.WasteId == x.WasteId
group new { x, z } by new { x.WasteId, z.Hazardous } into g
select new
{
nbrOf = g.Count(),
g.Key.Hazardous
}
).Where(a => a.nbrOf >= 1 && a.Hazardous == false)
select s
).Distinct();
答案 0 :(得分:1)
问题是你的where子句中有一个IQueryable。
尝试
...where( (from x in _db.WasteIndicators ... ).Any() )...
或者返回布尔值的东西。