Skip to content

Instantly share code, notes, and snippets.

@azcoov
Created January 23, 2011 02:13
Show Gist options
  • Save azcoov/791739 to your computer and use it in GitHub Desktop.
Save azcoov/791739 to your computer and use it in GitHub Desktop.
Linq Tag Cloud
var categories = from c in data.GraphicCategories
join g in data.Graphics on c.GraphicCategory_ID equals g.GraphicCategory_ID
group c by c.LongDescription into categoryGroup
select new
{
Category = categoryGroup.Key,
CategoryFrequency = categoryGroup.Count()
};
Int32 maxCategoryFrequency = (from c in categories select c.CategoryFrequency).Max();
var categoryCloud = from c in data.GraphicCategories
join g in data.Graphics on c.GraphicCategory_ID equals g.GraphicCategory_ID
group c by c.LongDescription into categoryGroup
select new
{
Category = categoryGroup.Key,
Weight = (Double)categoryGroup.Count() / maxCategoryFrequency * 100
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment