我有以下错误
Error 1 Cannot implicitly convert type 'LightSwitchApplication.PatientsTelephoneFollowupDetail' to 'bool'
Error 2 Cannot convert lambda expression to delegate type 'System.Func<LightSwitchApplication.PatientsTelephoneFollowupDetail,int,bool>' because some of the return types in the block are not implicitly convertible to the delegate return type
代码是
partial void StatusCallBackRequired_PreprocessQuery(ref IQueryable<PatientsTelephoneFollowupDetail> query)
{
query = query.Where(p=> p.PatientsMasterItem.PatientsTelephoneFollowupDetail.LastOrDefault(c => c.Status == "7" ));
}
我想将患者记录的最后一次电话状态恢复为7。
答案 0 :(得分:3)
.LastOrDefault
仍将返回PatientsTelephoneFollowupDetail
,正如错误所示,该值不是真值或假值。如果要检查项目是否存在,请使用.Any
:
query = query.Where(p => p.PatientsMasterItem.PatientsTelephoneFollowupDetail.Any(c => c.Status == "7"));
答案 1 :(得分:0)
Where
内的委托应该返回一个布尔值。
p => p.PatientsMasterItem.PatientsTelephoneFollowupDetail.LastOrDefault(c => c.Status == "7" )
肯定不会是一个。
你到底想做什么?
答案 2 :(得分:0)