Posted By

pauliehaha on 09/02/09


Tagged

Linq2Sql


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


Linq2Sql - Group By Count


 / Published in: C#
 

  1. public List<T> GetTotalRegisteredUserCount()
  2. {
  3. var qry = from aspnet_Profile profile in aspnet_Profiles
  4. group profile by profile.Country
  5. into grp
  6. select new {
  7. Country = grp.Key,
  8. Count = grp.Select(x => x.Country).Distinct().Count()
  9. };
  10. return qry.ToList();
  11. }

Report this snippet  

You need to login to post a comment.