User521171331 posted
Hi, how do I convert this query into linq query?
select c.categoryname, sum(unitprice) from Products p
inner join Categories c on p.CategoryID = c.CategoryID
group by c.Categoryname
This is what i got:
var groupbyResultJoin = (from product in dc.Products
join category in dc.Categories
on product.CategoryID equals category.CategoryID
group product by product.CategoryID into productCategory
select new { Category = productCategory.Key, Total = productCategory.Sum(s => s.UnitPrice) });
But, i want to select category name instead of category id. if i change it at group, then i can't get the unit price from product table.