linq多表分组查询
a表有数据bid与b表id相关,要按照a的字段name分组,b的字段time排序,只查询b全部字段,要求只取每个组的time最大的数据
------解决方案--------------------var query= from x in db.a
join y in db.b
on x.bid equals b.id
group x by x.name into g
select g.OrderByDescending(z=z.time).First();
------解决方案--------------------
var result = from u in db.TableB
orderby u.time descending
let n = db.TableA.Select(c => c.name)
group u by n into g
select g.FirstOrDefault();