我正在尝试将以下代码压缩为一个select语句。这可能吗?
if (atcCode.HasValue)
{
primaryOcc = (from f in db.aopFactor
where f.atcCode == atcCode
where f.endingDate == null
select f.primaryOccupancyID).FirstOrDefault();
}
var factorTable = (from f in db.aopFactor
where f.factorTypeID == factorType
where f.endingDate == null
where f.primaryOccupancyID == primaryOcc
select new { f.factorID, f.factorDescription }).ToDictionary(x => x.factorID, y => y.factorDescription);