Data model is one of the main three components of MVC
pattern and is actually responsible to maintain the state. Data model retrieves
data from data storage systems and passes the data to controllers. Often the
state data is stored in database storage system and you can retrieve them in
ASP.NET MVC framework doesn't care about your storage system
and all you need to do is pass your data to the controller classes somehow.
This may be via lower level APIs of ADO.NET like DataReader or DataSet or via
LINQ to SQL classes. Here for KBlog I'll use LINQ to SQL which will become
common in the near future (if we don't consider it as something common for real
world projects right now).
In general the data model is a proxy class that loads data
as objects and can pass them to controller classes. For simplicity many developers
prefer to use some extra helper classes that simplify the work with the data
model and encapsulate the inner workings to some extent. You'll see this later
in this article.