Summarize number of pages by page type

An edi­tor nee­ded infor­ma­tion about the num­ber pages for each page type on their site.

The following simp­le code will retri­e­ve all pages below the start page, group them by their page type name, and then count how many of each page type the­re is. It’s pro­bably much, *much* fas­ter to this via SQL, but I was fee­ling a bit lazy and did it this way ins­te­ad:

var result = DataFactory.Instance.GetDescendents(PageReference.StartPage)
	.OrderBy(page => page.PageTypeName)
	.GroupBy(page => page.PageTypeName)
	.Select(group => new { PageType = group.Key, Count = group.Count() })