Models
I currently have about 10 tables which are all sitting inside of a Linq2SQL dbml, I then have a Context class that managed the Linq2SQL database context.
For instance, let’s say I want to get entries, the Context class will make sure that the Linq2Sql context is up and retrieve all the entries
The ViewModels
Every View has a “ViewModel” associated with it. Let me give you an example.
For a blog, where you would like to view an Entry, the Entry might contain a title, content, tags and some comments.
The View Model for the View Entry (View) would look something like this
public class EntryViewModel
{
public Entry Entry { get; set; }
public List<Comment> Comments { get; set; }
public List<Tag> Tags { get; set; }
}
The Controllers
They perform pretty mondain tasks, such as begging the ViewModel for some data. i.e. I want to view entry "”Hello World”, go fetch the data for me. Which the ViewModel in turn requests from the Model.
The Views
They are pretty dumb alright, all they do is take the ViewModel they are given and display it the nicest way they can.
4db437f3-fcf5-4e81-bf23-c9a23f46e35c|0|.0