title: Mapping with self reference class
body: <p>I am trying to map the below Employee domain object to EmployeeViewModel using automapper.</p>
  
  <p>I am able to map properties like, Id, FirstName, LastName. But unable to map the Subordinates property.</p>
  
  <p>Used <code>Mapper.CreateMap&lt;Employee, EmployeeViewModel&gt;()</code>, but dont know how to map Subordinates property.</p>
  
  <p>Can anybody please help how to map the below classes.</p>
  
  <pre><code>public class Employee
  {
    public int Id {get; set;}
    public int FirstName{get; set;}
    public int LastName{get; set;}
    public Employee Manager{get; set;}
  }
  
  public class EmployeeViewModel
  {
    public int Id {get; set;}
    public int FirstName{get; set;}
    public int LastName{get; set;}
    public List&lt;Employee&gt; Subordinates {get; set;}
  }
  </code></pre>
  
  <p><strong>VIEW</strong></p>
  
  <pre><code>@helper ShowTree(IEnumerable&lt;EmployeeViewModel&gt; emp)
  {
  &lt;ul&gt;
      @foreach (var e in emp)
      {
          &lt;li&gt;
              @e.FirsyName
              @if (e.Children.Any())
              {
                  @ShowTree(e.Children)
              }
          &lt;/li&gt;
      }
  &lt;/ul&gt;
  }
  </code></pre>
  
  <p>Thanks,
  -Naren</p>