我想从这个Linq查询得到的是所有广告的列表,其中最近关联的日志与a LogType.IsStatus == true具有LogType.Name已确认或已更新.要清楚,广告有许多日志,每个日志有一个LogType.到目前为止,我有以下内容,但它在LastOrDefault上给出了一个错误System.NotSupportedException.
var adverts = (from a in database.Adverts
let lastLog = (from l in a.Logs
where l.LogType.IsStatus == true
orderby l.Created_at
select l).LastOrDefault()
where (lastLog != null)
&&
(lastLog.LogType.Name == "Confirmed" || lastLog.LogType.Name == "Renewed")
orderby a.Created_at descending
select a).ToList();
Run Code Online (Sandbox Code Playgroud)