title: Complex Nested Linq Query
body: <p>I'm looking to find all expense reports that are in a submitted state and were submitted prior to a given date ("days").
  Is there a better (faster, easier, cleaner) way to do this?</p>
  
  <pre><code>var startDate = DateTime.Now.AddDays(-days);
  using (var context = new Context())
  {
      var data = context.tExpenseReports
                      .AsNoTracking()
                      .Where(r =&gt; context.tTransactionStatuses.FirstOrDefault(s =&gt; s.TransactionStatusID == r.tTransactions.Max(t =&gt; t.TransactionStatusID)) != null ?
                                  context.tTransactionStatuses.FirstOrDefault(s =&gt; s.TransactionStatusID == r.tTransactions.Max(t =&gt; t.TransactionStatusID)).TransactionStatusID == IDConstants.TRANSACTION_STATUS_SUBMITTED &amp;&amp;
                                  context.tTransactionHistories.FirstOrDefault(s =&gt; s.TransactionStatusID == r.tTransactions.Max(t =&gt; t.TransactionStatusID)).CreatedDatetime &lt; startDate
                                  : false)
                .Execute()
                .Select(Mapper.Map&lt;tExpenseReport,ExpenseReport&gt;)
                .ToArray();
                return data;
            }
      }
  </code></pre>