我想选择每个客户所有订单项目的(已支付)价格总和。
以下是SQL命令:
SELECT c.name,SUM(oi.price * oi.count) from customer c
JOIN order o ON c.id=o.customer_id
JOIN order_item oi ON o.id=oi.order_id
JOIN bill b ON b.id=oi.bill_id
WHERE b.payment_id is NOT null
GROUP by c.name;
我不知道如何在EF中实现这个。
John Smith 1500,2
Allan Babel 202,0
Tina Crown 3500,78
(逗号被用作小数点……因为价格是小数值)