title: Getting grouped date range using linq
body: <p>I have this data that I have to group by price , and check the range and continouity of data</p>
  
  <pre><code>date            price
  2014-01-01  10
  2014-01-02  10
  2014-01-03  10
  2014-01-05  20
  2014-01-07  30
  2014-01-08  40
  2014-01-09  50
  2014-01-10  30
  </code></pre>
  
  <p>and the output should look like this</p>
  
  <pre><code>2014-01-01  2014-01-03  10
  2014-01-05  2014-01-05  20
  2014-01-07  2014-01-07  30
  2014-01-08  2014-01-08  40
  2014-01-09  2014-01-09  50
  2014-01-10  2014-01-10  30
  </code></pre>
  
  <p>I tried so far</p>
  
  <pre><code> var result = list
                  .OrderBy(a =&gt; a.Date)
                  .GroupBy(a =&gt; a.Price)
                  .Select(x =&gt; new
                  {
                      DateMax = x.Max(a =&gt; a.Date),
                      DateMin = x.Min(a =&gt; a.Date),
                      Count = x.Count()
                  })
                  .ToList()
                  .Where(a =&gt; a.DateMax.Subtract(a.DateMin).Days == a.Count)
                  .ToList();
  </code></pre>
  
  <p>I am not really sure this takes care of continuous dates. All dates are unique!</p>