title: DTO Pattern + Lazy Loading + Entity Framework + ASP.Net MVC + Auto Mapper
body: <p>Firstly, Sorry For lengthy question but I have to give some underlying information.</p>
  
  <p>We are creating an Application which uses ASP.net MVC, JQuery Templates, Entity Framework, WCF  and we used POCO as our domain layer. In our application, there is a WCF Services Layer to exchange data with ASP.net MVC application and it uses Data Transfer Objects (DTOs) from WCF to MVC.  </p>
  
  <p>Furthermore, the application uses Lazy Loading in Entity Framework by using AutoMapper when converting Domain-TO-DTOs in our WCF Service Layer. </p>
  
  <p>Our Backend Architecture as follows (<strong>WCF Services -> Managers -> Repository -> Entity Framework(POCO)</strong>)</p>
  
  <p>In our application, we don't use View Models  as we don't want another mapping layer for MVC application and we use only DTOs as View Models.</p>
  
  <p>Generally, we have Normal and Lite DTOs for domain such as Customer, CustomerLite, etc  (<strong>Lite object is having few properties than Normal</strong>).</p>
  
  <p>Now we are having some difficulties with DTOs because our DTO structure is becoming more complex and when we think maintainability (with general Hierarchical structure of DTOs) we lose Performance.</p>
  
  <p>For example, </p>
  
  <p>We have Customer View page and our DTO hierarchy as follows</p>
  
  <pre><code> public class CustomerViewDetailsDTO
   {
     public CustomerLiteDto Customer{get;set;}
     public OrderLiteDto Order{get;set;}
     public AddressLiteDto Address{get;set;}
   }
  </code></pre>
  
  <p>In this case we don't want some fields of OrderLiteDto for this view. But some other view needs that fields, so in order to facilitates that it we use that structure.</p>
  
  <p>When it comes to Auto Mapping, we map CustomerViewDetailsDTO and we will get additional data (which is not required for particular view) from Lazy Loading (Entity Framework).</p>
  
  <p>My Questions:</p>
  
  <ol>
  <li><p><strong>Is there any mechanism that we can use for improving performance while considering the maintainability?</strong></p></li>
  <li><p><strong>Is it possible to use Automapper with more map view based mapping functions for same DTO ?</strong></p></li>
  </ol>