8,497
社区成员
发帖
与我相关
我的任务
分享
select *
FROM Customer c
left join(
Select o.CustomerId ,sum(o.OrderTotalAmount) as OrderTotalAmount from [order] o
group by o.CustomerId
)ot
on c.id=ot.CustomerId
var query = from c in db.Customer
join ot in db.order.GroupBy(o=>o.CustomerId).Select(o=>new{CustomerId=o.Key,OrderTotalAmount=o.Sum(x=>x.OrderTotalAmount) })
on c.id equals ot.CustomerId into lg
from c in lg.DefaultIfEmpty()
select c;
var q =
from c in customer
join o in _orde on c.Id
equals o.CustomerId into orders
select new
{
c.Username,
OrderTotal = orders.Sum(i=>i.OrderTotal)
};