I'm using LINQ to SQL (SQL Server) within ASP.Net MVC. My page needs to display all Regions and all Offices within each Region (nested). Offices belong to a Suburb, which in turn, belong to a Region. I.e. Within each Region, I need to grab the Offices which exist inside Suburbs which belong to the current Region in the loop.
(Pseudo code)
foreach(Region currentRegion in Regions) { Display Region's Heading foreach(Office currentOffice in ALL OFFICES WHICH BELONG TO SUBURBS WHICH BELONG TO THIS REGION) { Display Office Name } }
What is the cleanest, MVC paradigm way to achieve this with LINQ to SQL?
(I'm a massive SQL fan, but I'm using LINQ to SQL for this project).
I don't want to have to write 5 helper classes just to do such a simple thing. I am not looking for a "perfect world OO overkill" solution, clean, minimalist and simple is best.
I'd ideally like to assemble all the data in the Controller so that I don't end up with some chaotic view that overlaps with Controller responsibility etc.
Many thanks..