title: Linq sorting, grouping, and returning a dictionary
body: <p>I have an array of custom objects (PONO) called FrameList, I can orderBy and GroupBy to sort and group. But now I want to return a dictionary, and I am getting the error:</p>
  
  <p><strong>(BTW, there is no error is I remove the .ToDictionary() method. )</strong></p>
  
  <blockquote>
    <p>Error 1   'System.Linq.IGrouping' does
    not contain a definition for 'type' and no extension method 'type'
    accepting a first argument of type
    'System.Linq.IGrouping' could be found
    (are you missing a using directive or an assembly
    reference?)   C:\Users\ysg4206\Documents\Visual Studio
    2010\Projects\Watson\CatalogServiceClasses\BuildToby.cs   21  38  Watson</p>
  </blockquote>
  
  <p>Here is the snippet that sorts and groups:</p>
  
  <pre><code>    var dict = request.FrameList.OrderBy(f =&gt; f.trueDate)
          .GroupBy(f =&gt; f.type)
          .ToDictionary(f =&gt; f.type, f =&gt; f);
  </code></pre>
  
  <p>and here is the definition of the FrameList (which is a simple array of FrameData)</p>
  
  <pre><code>[DataContract]
  public class FrameData
  {
      [DataMember]
      public String idx { get; set; }
      [DataMember]
      public String type { get; set; }
      [DataMember]
      public String path { get; set; }
      [DataMember]
      public String date { get; set; }
      [DataMember]
      public DateTime trueDate { get; set; }
  }
  </code></pre>