title: Entity Framework Include Single Object from One-To-Many Relationship
body: <p>I'm trying to construct a single query to fetch the list of all Tour objects, with each tour's latest version preloaded (latest being most recently created). See the models below. Each <code>Tour</code> can have multiple associated <code>TourVersion</code> objects</p>
  
  <pre><code>class Tour {
      public Guid TourId { get; set; }
      public virtual TourVersion CurrentTourVersion { get; set; }
      // Other properties etc.
  }
  class TourVersion {
      public Guid TourId { get; set; }
      public DateTime CreatedOn { get; set; }
      // Other properties etc.
  }
  </code></pre>
  
  <p>I'm able to accomplish what I want running another query for each <code>Tour</code>:</p>
  
  <pre><code>var tours = context.Tours.ToList();
  
  foreach (var tour in tours)
  {
      tour.CurrentTourVersion = context.TourVersions
          .Where(t =&gt; t.TourId == tour.Id)
          // ToUnixTime is a custom extension method that returns a long
          .OrderByDescending(t =&gt; t.CreatedOn.ToUnixTime())
          .FirstOrDefault();
  }
  </code></pre>
  
  <p>I'd like to be able to accomplish this in a single query. Any suggestions?</p>