title: AutoMapper best practices - Should I be asking the DAO for information to fulfill mapping from DTO to domain object?
body: <pre><code>/// &lt;summary&gt;
  ///     Initialize the AutoMapper mappings for the solution.
  ///     http://automapper.codeplex.com/
  /// &lt;/summary&gt;
  public static void CreateAutoMapperMaps()
  {
      IDaoFactory daoFactory = DependencyResolver.Current.GetService&lt;IDaoFactory&gt;();
  
      Mapper.CreateMap&lt;Error, ErrorDto&gt;()
              .ReverseMap();
  
      IPlaylistDao playlistDao = daoFactory.GetPlaylistDao();
      IUserDao userDao = daoFactory.GetUserDao();
  
      Mapper.CreateMap&lt;Playlist, PlaylistDto&gt;();
      Mapper.CreateMap&lt;PlaylistDto, Playlist&gt;()
              .ForMember(playlist =&gt; playlist.User, opt =&gt; opt.MapFrom(playlistDto =&gt; userDao.Get(playlistDto.UserId)));
  
      Mapper.CreateMap&lt;PlaylistItem, PlaylistItemDto&gt;();
      Mapper.CreateMap&lt;PlaylistItemDto, PlaylistItem&gt;()
              .ForMember(playlistItem =&gt; playlistItem.Playlist,
                          opt =&gt; opt.MapFrom(playlistItemDto =&gt; playlistDao.Get(playlistItemDto.PlaylistId)));
  
      Mapper.CreateMap&lt;ShareCode, ShareCodeDto&gt;().ReverseMap();
  
      Mapper.CreateMap&lt;User, UserDto&gt;().ReverseMap();
      Mapper.CreateMap&lt;Video, VideoDto&gt;().ReverseMap();
  
      Mapper.AssertConfigurationIsValid();
  }
  </code></pre>
  
  <p>A friend is telling me that it is bad practice for AutoMapper to rely on DAOs to fulfill mappings from DTO to Domain.</p>
  
  <p>I don't understand why this is bad practice nor do I understand how it would be possible to effectively work on my domain object with null references.</p>
  
  <p>Can anyone explain? Thanks</p>