title: Data Mapper Pattern
body: <p>Up until now I've been using Active records in all my c# database driven applications. But now my application requires my persistence code being split from my business objects. I have read a lot of posts regarding Martin Fowler's data mapping pattern, but my knowledge of this pattern is still very limited. </p>
  
  <p>Let's use the following example:</p>
  
  <p>If I have 2 tables - Customer and CustomerParameters. The CustomerParameters table contains default Customer values for creating a new Customer. </p>
  
  <p>I will then have to create a CustomersMapper class to handle all of the Customer persistence. My Customer and CustomersList class will then collaborate with this mapper class in order to persist customer data.</p>
  
  <p>I have the following questions:</p>
  
  <ol>
  <li><p>How would I transfer raw data TO &amp; FROM my Customer class to the mapper without breaking certain business rules? DTO's?</p></li>
  <li><p>Is it acceptable to have a SaveAll and LoadAll method in my Mapper class for updating and loading multiple customers' data? If so, in case of SaveAll, how will the mapper know when to update or insert data?</p></li>
  <li><p>Will the Customer mapper class be responsible for retrieving the default values from the CustomerParameters table as well, or will it be better to create a CustomerParameters mapper?</p></li>
  </ol>
  
  <p>A O/R mapper tool is not really here. The database I'm using is Transactional and requires that I write my own Mapper Pattern.</p>
  
  <p>Any ideas and comments will be greatly appreciated.</p>