P
Phil
I have a many to many relationship Articles <-> Categories. Each article
can belong to many categories, and each category can belong to more than one
article. I can get the total number of articles within each category:
public IEnumerable<MenuCategory> GetMenuCategories()
{
return (from c in db.CategorySet.Include("Articles")
orderby c.CategoryName
select new MenuCategory
{
CategoryID = c.CategoryID,
CategoryName = c.CategoryName,
CountOfCategory = c.Articles.Count()
});
}
But I also need to get the total number of articles so that I can calculate
what percentage of articles is in each category. Can anyone tell me how to
do that?
Thanks
can belong to many categories, and each category can belong to more than one
article. I can get the total number of articles within each category:
public IEnumerable<MenuCategory> GetMenuCategories()
{
return (from c in db.CategorySet.Include("Articles")
orderby c.CategoryName
select new MenuCategory
{
CategoryID = c.CategoryID,
CategoryName = c.CategoryName,
CountOfCategory = c.Articles.Count()
});
}
But I also need to get the total number of articles so that I can calculate
what percentage of articles is in each category. Can anyone tell me how to
do that?
Thanks