title: How do we retrieve the first item of a WhereSelectListIterator?
body: <p>How do we retrieve the first item of a <code>WhereSelectListIterator</code>? Usually, I use a <code>foreach</code> loop to iterate. Is there a way to call the equivalent of <code>myResult[0]</code> or <code>myResult.FirstOrDefault()</code>. Both throw an error. <code>myResult.ToList()</code> doesn't work either. I am beginning to think that the only thing we can do with a <code>WhereSelectListIterator</code> is iterate with <code>foreach</code>.</p>
  
  <p>Here is the scenario: I have created an Orchard Query with a Shape layout. The Shape Template contains the following code:</p>
  
  <pre><code>@{
      // content items is of type WhereSelectListIterator&lt;T,T&gt;
      var contentItems = Model.ContentItems;
      dynamic firstItem = null;
  
      // {"Cannot apply indexing with [] to an expression of type 'object'"}
      //// firstItem = contentItems[0];
  
      // {"'object' does not contain a definition for 'ToList'"}
      // var items = contentItems.ToList();
  
      // get the title of the first content item
      // this is what DOES work
      foreach (var contentItem in contentItems)
      {
          firstItem = contentItem;
          break;
      }
  }
  
  &lt;h2&gt;@(firstItem != null ? firstItem.TitlePart.Title : "Got Nothing")&lt;/h2&gt;
  </code></pre>
  
  <p>Specifically, <code>contentItems</code> was of type </p>
  
  <pre><code>System.Linq.Enumerable.WhereSelectListIterator&lt;
      Orchard.Projections.Descriptors.Layout.LayoutComponentResult,
      Orchard.ContentManagement.ContentItem&gt;
  </code></pre>
  
  <p>Please let me know if you need more details about why I might want to retrieve the first item.</p>