title: MVC and Automapper multiple level of nesting
body: <p>I am starting off with MVC and auto mapper and would appreciate some guidance.I have some domain models and a view model which is a combination of these domain models. Basically there are 4 classes</p>
  
  <p><code>Transcription</code> has an associated <code>Audio</code> which is owned by a <code>Client Staff</code> who has a userid in <code>Users</code></p>
  
  <p>Database relationship diagram:</p>
  
  <p><a href="http://i49.tinypic.com/whcwsz.jpg" rel="nofollow">http://i49.tinypic.com/whcwsz.jpg</a></p>
  
  <p>Domain models EF generated (Only relevant fields)</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>public class audio
  {
      public int AudioID { get; set; }
      public string AudioLength { get; set; }
      public virtual ClientStaff ClientStaff { get; set; }
      public virtual ICollection&lt;Transcription&gt; Transcriptions { get; set; }
  }
  
  public class ClientStaff
  {
      public int ClientStaffID { get; set; }
      public int StaffType { get; set; }
      public int ClientID { get; set; }
      public virtual ICollection&lt;Audio&gt; Audios { get; set; }
      public virtual User User { get; set; }
  }
  
  public class User
  {
      public int UserID { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }    
      public virtual ICollection&lt;ClientStaff&gt; ClientStaffs { get; set; }
  }
  
  public class Transcription
  {
      public int TranscriptionID { get; set; }
      public string TranscriptionText { get; set; }
      public virtual Audio Audio { get; set; }
      public Nullable&lt;int&gt; AudioID { get; set; }
  }
  </code></pre>
  
  <p>View model</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class customVM
  {
      public int AudioID { get; set; }//get from audio
      public string Path { get; set; }//get from audio
      public string AudioLength { get; set; }//get from audio
      public DateTime AudioCreatedOn { get; set; }//get from audio
      public int ClientStaffID { get; set; }//get from audio
      public string TranscriptionText { get; set; }//get from transcription
      public DateTime TranscriptionCreatedOn { get; set; }//get from transcription
      public string UsersFirstName { get; set; }//get from users
      public string UsersLastName { get; set; }//get from users 
  }
  </code></pre>
  
  <p>Controller action</p>
  
  <pre class="lang-cs prettyprint-override"><code>public ActionResult Index()
  {
      IEnumerable&lt;Audio&gt; x= db.getAudioFiles();
      Mapper.CreateMap&lt;Audio, customVM&gt;();
      IEnumerable&lt;customVM&gt; model =
          Mapper.Map&lt;IEnumerable&lt;Audio&gt;, IEnumerable&lt;customVM&gt;&gt;(x);
      Mapper.AssertConfigurationIsValid();
  
      return View(model);
  }
  </code></pre>
  
  <p>The problem :</p>
  
  <p><code>AutoMapper</code> is picking up properties from <code>Transcription</code> and <code>ClientStaff</code> but how do I get the user first names and last names? Or rather to generalise how do I get a 2nd level nested class properties with auto mapper. Or am I approaching the whole issue incorrectly ?</p>