我想为每个客户选择一个订单项目的所有(付费)价格的总和。这是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
(逗号用作小数点..因为价格是十进制值)