forum

Home / DeveloperSection / Forums / using group by in linq in controller

using group by in linq in controller

Manish Kumar128825-May-2017

currently i have following linq

  ViewBag.Products = db.Transaction.GroupBy(n => n.ProductName,
              (key, values) => new { ProductName = key, Count = values.Count() });


in view i need to get  the list of each product and its count

but in view i get the query printed

if i use productid i get productid      count

i want to group by productid but name and count shld be displayed

requirement  

product1       20

product2        18

product3         4


Updated on 28-May-2017

Can you answer this question?


Answer

1 Answers

Liked By