直接上代码留记
var list = (from item in
(from tb1 in fileDirList
join tb2 in fileInfoList
on tb1.FileDirId equals tb2.FileDirId into tmp
from f in tmp.DefaultIfEmpty()
select new
{
FileCount = tmp.Where(w => w.FileDirId == f.FileDirId).Count(),
FileDirName = tb1.FileDirName,
NeedFiles = tb1.NeedFiles
})
group item by item.FileDirName into query
select new CheckFileCountDto
{
FileDirName = query.Max(m => m.FileDirName),
FileCount = query.Max(m => m.FileCount),
NeedFiles = query.Max(m => m.NeedFiles)
}).ToList();
结果: