Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

LINQ - Group by with aggregate functions in C#

Example:
  1. using System;
  2. using System.Linq;
  3. using System.Xml.Linq;
  4.  
  5. namespace ForgetCode
  6. {
  7. public class MainClass
  8. {
  9. public static void Main()
  10. {
  11. dat customers = new dat(@"c:\data.mdf");
  12.  
  13. var custQuery =
  14. from cust in customers
  15. group cust by cust.City into custGroup
  16. where custGroup.Count() > 2
  17. orderby custGroup.Key
  18. select custGroup;
  19. }
  20. }
  21. }