What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 9596 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > LINQ > Group By Using LINQ ...
Vishalbedre

Group By Using LINQ

 Code Snippet posted by: Vishalbedre | Posted on: 10/10/2012 | Category: LINQ Codes | Views: 430 | Status: [Member] | Points: 40 | Alert Moderator   


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 http://www.dotnetfunda.com/articles/article993-frequently-used-linq-extension-methods.aspx
Thanks
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/23/2013 12:26:08 PM