title: C# Automapper Nested Object
body: <p>Ive searched for this for few days now and cant seem to get anything to work, I am using c# MVC Entity Framework with Automapper and im trying to achieve the below ViewModels (mainly LostDocumentVM) to be mapped from my database, all other properties will be set in controllers.</p>
  
  <p>Here is my ViewModels...</p>
  
  <pre><code>DocumentVM
  {
      Public Enum.HistoricType HistoricType {get;set;}
      Public DocumentChildVM Document { get; set;}
  }
  
  DocumentChildVM
  {
      Public bool ShowHistoricLink {get;set;}
      Public IEnumerable&lt;ListDocumentVM&gt; DocumentsToReview {get;set;}
  }
  
  ListDocumentVM
  {
      Public int Id {get;set;}
      Public string Name {get; set;}
      Public DateTime? ReviewDate {get;set;}
  }
  </code></pre>
  
  <p>I initialise the DocumentVM like this...</p>
  
  <pre><code>DocumentVM documentVM = DataContext.SystemUser.Where(x=&gt;x.SustemUserID==LoggedOnUserID).Project().To&lt;DocumentVM&gt;().SingleOrDefault();
  </code></pre>
  
  <p>And my mapping is like this...</p>
  
  <pre><code>Mapper.CreateMap&lt;SystemUser,DocumentVM&gt;()
  .ForMember(dest=&gt;dest.Document.DocumentsToReview, opt=&gt;opt.MapFrom(src=&gt;src.Documents.Where(x=&gt;x.DocumentType == Enum.DocumentType.Assessment));
  </code></pre>
  
  <p>Im new to AutoMapper and struggling to get more advanced mappings to work.</p>