title: Searching for an item in a list that's nested inside another list based on a property value in C# using LINQ?
body: <p>Is there a way to search for an item in a list that's nested inside another list based on a property value using LINQ?</p>
  <p>Given the follow models below, for a given Order (variable <code>customerOrder</code>), I want to return the earliest order date (<code>Date</code>) where the Day is &quot;Sunday&quot;.</p>
  <p>models:</p>
  <pre><code>public class Order
  {
      public int Id { get; set; }
      public List&lt;OrderLine&gt; OrderLines { get; set; }
  }
  
  public class OrderLine
  {
      public string Description { get; set; }
      public List&lt;OrderDate&gt; OrderDates { get; set; }
  }
  
  public class OrderDate
  {
      public DateTime Date { get; set; }
      public string Day { get; set; }
  }
  </code></pre>
  <p>code:</p>
  <pre><code>var dates = new List&lt;DateTime&gt;();
  foreach(var a in customerOrder.OrderLines)
  {
      var orderDate = a.OrderDates.Where(x =&gt; x.DateTypeId.Equals(&quot;Sunday&quot;)).FirstOrDefault();
      dates.Add(orderDate.ActualDate);
  }
  dates.OrderBy(d =&gt; d.Date);
  
  return dates.FirstOrDefault();
  </code></pre>