SQL 查询 VS LinQ
select v.Branch, v.Store, v.ChildId,SUM(r.Cash) from OrderDetail as r
inner join Order as v on r.OrderId equals v.Id
where r.OrderId == 123
group by v.Branch, v.Store, v.ChildId
LinQ
var list = (from r in ctx.OrderDetail
join v in ctx.Order on r.OrderId equals v.Id
where r.OrderId == 123
group new { v, r } by new { v.Branch, v.Store, v.ChildId } into g
select new
{
Branch = g.Key.Branch,
Store = g.Key.Store,
ChildId = g.Key.ChildId,
TotalCash = g.Sum(p => p.r.Cash)
}