Skip to content

Instantly share code, notes, and snippets.

@aaronpowell
Created April 14, 2014 05:29
Show Gist options
  • Select an option

  • Save aaronpowell/10618558 to your computer and use it in GitHub Desktop.

Select an option

Save aaronpowell/10618558 to your computer and use it in GitHub Desktop.
Number of document type properties grouped by document type and ordered by the number of documents using them
CmsPropertyTypes
.GroupBy(pt => pt.ContentTypeId)
.Join(CmsDocumentTypes, x => x.Key, x => x.ContentTypeNodeId, (pts, dt) => new {
Property = pts,
DocumentType = dt
})
.Join(UmbracoNodes, x => x.DocumentType.ContentTypeNodeId, x => x.Id, (x, n) => new {
x,
n.Text
})
.Select(x => new {
x.x.Property.Key,
x.Text,
PropertyCount = x.x.Property.Count(),
DocCount = CmsContents.Where(c => c.ContentType == x.x.Property.Key).Where(c => !c.Node.Trashed).Count()
})
.Distinct()
.OrderByDescending(x => x.DocCount)
.ThenBy(x => x.PropertyCount)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment