title: LINQ GroupBy month
body: <p>I am having trouble getting an IQueryable list of a (subsonic) object grouped by Month and Year.</p>
  
  <p>Basic view of the object...</p>
  
  <pre><code>public partial class DatabaseObject
  {
      [SubSonicPrimaryKey]
      public int objectID { get; set; }
  
      public string Description { get; set; }
  
      public decimal Value { get; set; }
  
      public string Category { get; set; }
  
      public DateTime DateOccurred { get; set; }
  }
  </code></pre>
  
  <p>Method to get IQueryable in my Database repository...</p>
  
  <pre><code>public IQueryable GetData(string DataType)
  {
     return (from t in db.All&lt;DatabaseObject&gt;()
             orderby t.DateOccurred descending
             select t)
            .Where(e =&gt; e.Category == DataType);  
  }
  </code></pre>
  
  <p>My question is, how can I return the dates grouped by Month? I have tried the below, but this results in compiler warnings regarding anonymous types...</p>
  
  <pre><code>public IQueryable GetData(string DataType)
  {
     var datalist = (from t in db.All&lt;FinancialTransaction&gt;().Where(e =&gt; e.Category == DataType);
                     let m = new
                     {
                         month = t.DateOccurred.Month,
                         year = t.DateOccurred.Year
                     }
                     group t by m into l select new
                     {
                         Description = string.Format("{0}/{1}", l.Key.month, l.Key.year),
                         Value = l.Sum(v =&gt; v.Value), // Sum(v =&gt; v.Value),
                         Category = "Grouped"
                         DateOccurred = l.Last(v =&gt; v.DateOccurred)
                     }
      return datalist;
  }
  </code></pre>
  
  <p>Any ideas?</p>