Here are my two tables
BuyShare
SoldShare
and the result table i want from LINQ query is
This result table contain companies name with there total buy and sold shares.
So far I code is:
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)
};
but I can't get desired result.