title: How and where to implement automapper in WPF application
body: <p>I have<code>BusinessLayer, DTO library,DataService, EntityModel(wher EDMX sits)</code>, DTO library refers to both business and data layer. I am trying to implement <code>automapper</code> in data layer, want to map entity object to DTO object and return DTO from the <code>dataService</code> library.</p>
  
  <p>Currently am doing this way</p>
  
  <pre><code>public class DataService
  {
      private MapperConfiguration config;
      public DataService()
      {
          IMapper _Mapper = config.CreateMapper(); 
      }
  
      public List&lt;Dto.StudentDto&gt; Get()
      {
          using(var context = new DbContext().GetContext())
          {
              var studentList =  context.Students.ToList();
              config = new MapperConfiguration(cfg =&gt; {
                  cfg.CreateMap&lt;Db.Student, Dto.StudentDto&gt;();
              });
              var returnDto = Mapper.Map&lt;List&lt;Db.Student&gt;, List&lt;Dto.StudentDto&gt;&gt;(studentList);
              return returnDto;
          }
      }
  }
  </code></pre>
  
  <p>How can I move all the mappings to one class and automapper should initialize automatically when call to dataserive is made? </p>