How do I get a linq to sql group by query into the asp.net mvc view?
- by Brad Wetli
Sorry for the newbie question, but I have the following query that groups parking spaces by their garage, but I can't figure out how to iterate the data in the view. I guess I should strongly type the view but am a newbie and having lots of problems figuring this out. Any help would be appreciated.
Public Function FindAllSpaces() Implements ISpaceRepository.FindAllSpaces
Dim query = _
From s In db.spaces _
Order By s.name Ascending _
Group By s.garageid Into spaces = Group _
Order By garageid Ascending
Return query
End Function
The controller is taking the query object as is and putting it into the viewdata.model and as stated the view is not currently strongly typed as I haven't been able to figure out how to do this. I have run the query successfully in linqpad.