Mapping Data to Models in C#

Mapping Data to Models in C#: Mapping Data to Models: an overview, Model Review, Mapping Rows to Models, Data Access Objects, Example: a Product DAO.

Updated

  1. Mapping Data to Models: an overview (Journeyman): Instead of using each row the moment it's read, copy it into a model object, so the program can keep and reuse the data after the reader is gone.
  2. Model Review (Journeyman): Write a model class with one property for each column, choosing C# types that match the SQL types, and nullable types for columns that allow NULL.
  3. Mapping Rows to Models (Journeyman): Read each row of a query into a new model object, handle NULL columns, and collect the objects in a List<T>.
  4. Data Access Objects (Journeyman): Gather all the SQL for one table into a Data Access Object (DAO), so the rest of the program asks for models and never sees the database.
  5. Example: a Product DAO (Journeyman): A complete ProductDao for Northwind, with methods to get, search, add, update and delete products, all with parameters and one mapping method.