title: How can i make AutoMapper generate this code automatically?
body: <p>I'm new using Automapper i searched a lot for a right answer but it seems i can't get it in my mind correctly so:</p>
  
  <p>i have this block of code </p>
  
  <pre><code>    var user = usersDao.FindById(HttpContext.Current.User.Identity.GetUserId());
      var userDto = Mapper.Map&lt;ApplicationUser, UserDto&gt;(user);
          if (user.Student != null)
          {
           userDto.Account = Mapper.Map&lt;Student, StudentDto&gt;(user.Student);
          }
          if (user.Teacher != null)
          {
          userDto.Account = Mapper.Map&lt;Teacher, TeacherDto&gt;(user.Teacher);
          }
          userDto.Account.User = null;
  </code></pre>
  
  <p>so what i'm trying  to do is i have this property in my <code>UserDto</code> class</p>
  
  <p><code>AccountDto Account</code></p>
  
  <p>both <code>StudentDto</code> and <code>TeacherDto</code> inherited From it
  so i want to make automapper to do self auto mapping to it, if it is from <code>StudentDto</code> or <code>TeacherDto</code> to <code>Account</code></p>
  
  <p>here is the classes</p>
  
  <pre><code>public class StudentDto : AccountDto
      {
  
      }
  public class TeacherDto: AccountDto
      {
  
      }
  public class AccountDto 
      {
          public UserDto User { get; set; }
          public string UserId { get; set; }
  
      }
  public class UserDto 
  {
      public AccountDto Account { get; set; }
  }
  </code></pre>
  
  <p>is there a simple solution?</p>