小编Jay*_*Jay的帖子

Linq带有子查询

我想从这个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)

c# linq linq-to-entities

3
推荐指数
1
解决办法
5686
查看次数

标签 统计

c# ×1

linq ×1

linq-to-entities ×1