Now, I realize that this question has been answered before, but I just can’t warp my head around it and make it work in my example:
View
should contain 2 foreach loops fx
foreach(var item in Model.ListA)
foreach(var item in Model.ListB)
Model
should contain a class with a LinqDataContext object and two properties: (ListA and ListB)
Controller
should pass the Model through the View.
How would the Model and Controller look to achieve this?
Some simple code examples would be really helpful 🙂
You’ve got it a bit backward. Your data context should be in the controller (preferably in a layer even lower that the controller uses). You always want your controller responsible for getting/updating data, and populating the model. Then, the model is delivered to the view with everything needed for the presentation of that data.