title: Group by year and month with given date range using Lambda or LINQ Query
body: <p>I have a List with the following type of objects. The list currently in ascending order.</p>
  
  <pre><code>public class ReportsCountByDate{
      public int  CountOfReports { get ; set ;}
      public DateTime ReportGeneratedDate { get ;set ;}  
  }
  </code></pre>
  
  <p>My Data Set:</p>
  
  <pre><code>CountOfReports     ReportGeneratedDate
  3                  2017-02-07
  5                  2017-02-21
  5                  2017-03-12
  1                  2017-05-03
  4                  2017-05-23
  3                  2017-06-12
  </code></pre>
  
  <p>[Please note that there is no repot for 2017 April]
  If I need to get report count from 2017 January to 2017 July.</p>
  
  <pre><code>CountOfReports  YearAndMonth 
  0               2017-01 
  8               2017-02
  5               2017-03
  0               2017-04
  5               2017-05
  3               2017-06
  0               2017-07
  </code></pre>
  
  <p>Can someone point me out how to get following result using <code>Lambda</code> or <code>LINQ</code> query.</p>
  
  <p>Update : </p>
  
  <p>Here is my code.</p>
  
  <pre><code>var startYear = input.durationStartDate.Year;
  var startMonth = input.durationStartDate.Month;
  
  var endYear = input.durationEndDate.Year;
  var endMonth = input.durationEndDate.Month;
  
  var yearRange = (endYear - startYear) == 0 ? 1 : (endYear - startYear);
  
  var monthRange = ((input.durationEndDate.Year - input.durationStartDate.Year) * 12 + input.durationEndDate.Month - input.durationStartDate.Month) == 0 ? 1 : ((input.durationEndDate.Year - input.durationStartDate.Year) * 12 + input.durationEndDate.Month - input.durationStartDate.Month);
  
  
  
  var desposition = await _dispositionSummaryManager.GetDispositionFormByCreateDate(input.platform, input.durationStartDate, input.durationEndDate);
  
  var changesPerYearAndMonth =
                     from year in Enumerable.Range(startYear, yearRange)
                     from month in Enumerable.Range(startMonth, monthRange)
                     let key = new { Year = year, Month = month }
                     join ReportsCountByDate in desposition on key
                               equals new
                               {
                                   ReportsCountByDate.ReportGeneratedDate.Year,
                                   ReportsCountByDate.ReportGeneratedDate.Month
                               } into g
                     select new { GroupCriteria = key, Count = g.Count() };
  </code></pre>