这是我的两张桌子
买股
出售股份
我想要的 LINQ 查询的结果表是
此结果表包含公司名称以及总买卖股份。
到目前为止,我的代码是:
var userHistoryAll = from buy in db.share_bought_history
join sold in db.share_sold_history
on buy.regist_id equals sold.regist_id
select new
{
buy,
sold
} into combine
group combine by combine.buy.comapnay_id
into final
select new
{
cName = final.FirstOrDefault().buy.company.company_name,
uBuy = final.Sum(x => x.buy.no_of_sahre),
uSold = final.Sum(x => x.sold.no_of_sahre)
};
但我无法得到想要的结果。