Group By Using LINQ

Posted by Vishalbedre under LINQ category on | Points: 40 | Views : 1305
Here is the code snippet of Group By using LINQ. IN this we have taken the tables from Northwind database and joined them.
 var data = from c in db.Customers
join o in db.Orders
on c.CustomerID equals o.CustomerID
select new
CustomerName = c.ContactName,
ORderId = o.OrderID

var d = from dd in data
group dd by dd.CustomerName into g
select new
cNAme = g.Key,
rCount = g.Count()

For more LINQ related methods visit

Comments or Responses

Login to post response