title: How to perform LINQ operation after nested AutoMapper Project().To<>()
body: <p>I have nested Selects in C# LINQ and want to transform them to AutoMapper projections.</p>
  
  <p>This is part of my original query:</p>
  
  <pre><code>.ThenByDescending(s =&gt; s.CreatedOn)
  .Select(s =&gt; new SubmissionDetailsViewModel
              {
                  // some mappings
                  Tests = s.TestRuns
                      .Select(tr =&gt; new TestRunViewModel
                      {
                          OrderBy = tr.Test.IsTrialTest ? TestCategoryType.Example : tr.Test.CategoryType,
                          // some other mappings
                      })
                      .GroupBy(tr =&gt; tr.OrderBy)
                      .OrderBy(tr =&gt; tr.Key)
              })
  </code></pre>
  
  <p>How can I configure AutoMapper to make the projection and then call GroupBy on the projected nested view model. Using Project().To() instead of the nested Select does not compile because of optional parameters in the expression. I tried using AfterMap() but it does not do the trick. Should I do the following: </p>
  
  <pre><code>.CreateMap&lt;ICollection&lt;TestRun&gt;, IOrderedEnumerable&lt;IGrouping&lt;TestCategoryType, TestRunViewModel&gt;&gt;&gt;()
              .ProjectUsing()
  </code></pre>
  
  <p>And then copy the nested Select? But in this way I need to type the select myself and not let AutoMapper to project it for me. Any suggestions?</p>
  
  <p>Thank you in advance!</p>