title: AutoMapper complex nested mappings
body: <p>I've read <a href="http://docs.automapper.org/en/stable/Nested-mappings.html" rel="nofollow noreferrer">this example on AutoMapper's GitHub</a>, but the example assumes there'll only be one way to map InnerSource, ever:</p>
  
  <pre><code>Mapper.CreateMap&lt;OuterSource, OuterDest&gt;();
  Mapper.CreateMap&lt;InnerSource, InnerDest&gt;();
  Mapper.AssertConfigurationIsValid();
  
  var source = new OuterSource
      {
          Value = 5,
          Inner = new InnerSource {OtherValue = 15}
      };
  
  var dest = Mapper.Map&lt;OuterSource, OuterDest&gt;(source);
  </code></pre>
  
  <p>With my project, I'm serializing objects created with EF that have circular references. The reason for this is I will need to come at the objects from different 'directions.' For example, if I ask for a list of users, I want to see the projects they're associated with. If I ask for a project, I want to see the users associated with that project.</p>
  
  <p>These circular references can get fairly deep, like <code>User.Role.Project.TaskTime.User</code>, <code>User.TaskTime.Project.Task.TaskType.VisibleToRole.Role.User</code>, etc.</p>
  
  <p>So I need the nested mapping to be fairly deep, and the way it's done depends on what the first mapping was.</p>
  
  <p>Currently I'm doing:</p>
  
  <pre><code>Mapper.CreateMap&lt;User, UserFull&gt;()
      .ForMember("TaskTimes", opt =&gt; opt.MapFrom(src =&gt; Mapper.Map&lt;ICollection&lt;TaskTime&gt;, UserTaskTime&gt;(src.TaskTimes)));
  Mapper.CreateMap&lt;TaskTime, UserTaskTime&gt;()
      .ForMember("Task", opt =&gt; opt.MapFrom(src =&gt; Mapper.Map&lt;Task, UserTaskTimeTask&gt;(src.Task)));
  //...
  </code></pre>
  
  <p>The viewmodels for that snippet look like this:</p>
  
  <pre><code>public class UserFull
  {
      public string Email { get; set; }
      public string Name { get; set; }
  
      public virtual ICollection&lt;TaskTime&gt; TaskTimes { get; set; }
      //...
  }
  
  public class UserTaskTime
  {
      public int Id { get; set; }
      public Task Task { get; set; }
      //...
  }
  
  public class UserTaskTimeTask
  {
      //...
  }
  </code></pre>
  
  <p>Is this right? Should I be projecting each member from the viewmodel and mapping it by hand using projection? Or is there a cleaner way to do this?</p>