我想将此查询转换为LINQ。
select sup.firstname, sup.lastname, sup.bankaccountnumber, tbl.total from (select nfcids_id, sum(purchasecost) as total
from tbl_milkpurchases
group by nfcids_id) tbl inner join tbl_nfcids nfc on tbl.nfcids_id = nfc.id inner join tbl_suppliers sup on nfc.suppliers_id = sup.id
答案 0 :(得分:2)
尝试此查询
var obj= from a in Context.tbl_milkpurchases.GroupBy(x=>x.nfcids_id).Select(x=>new{x.nfcids_id,total=Sum(x.purchasecost)})
from b in Context.tbl_nfcids.where(x=>x.id==a.nfcids_id)
from c in Context.tbl_suppliers.where(x=>x.id==b.suppliers_id)
Select new{c.firstname, c.lastname, c.bankaccountnumber, a.total}