Hello everyone,
I got the following setup for my database:
Category Table (Fields: CategoryID(PK), Title);
Menu Table (Fields: MenuID(PK) CategoryID(FK), Title);
Page Table (Fields PageID(PK), MenuID(FK), Title, Content, CreatedOn);
Now for one page I want to know how many Pages a particular category holds. I have no clue how to make such query with SubSonic. The way I'm doing it now is like this:
int count = 0;
DAL.MenuCollection coll = new DAL.MenuCollection().WHERE(DAL.ObjectMenu.Columns.CategoryID, _catid);
foreach(DAL.Menu item in coll)
{
DAL.PageCollection collTemp = new DAL.PageCollection().WHERE(DAL.Page.Columns.MenuID, _menuid);
count+= collTemp.Count;
}
This will work but isn't there a better way to write it within a single statement? This looks kinda bad I think,
I Hope someone can point me in the right direction. Thank you for reading Kind regard,s Mark