title: Selecting Consecutive Entries with LINQ to Entities
body: <p>I have a database table with rows that each contain a sequential index. I want to select groups of rows that are consecutive based upon this index column. For example, if I had rows with the following index values:</p>
  
  <pre><code>1
  3
  4
  5
  7
  9
  10
  11
  12
  15
  16
  </code></pre>
  
  <p>and I wanted to select all groups with 3 consecutive indices (this number will vary). I would get the following groups:</p>
  
  <pre><code>3, 4, 5
  
  9, 10, 11
  
  10, 11, 12
  </code></pre>
  
  <p>Basically, I'm trying to achieve something similar to the question posed here:</p>
  
  <p><a href="https://stackoverflow.com/questions/2334535/selecting-consecutive-numbers-using-sql-query">selecting consecutive numbers using SQL query</a></p>
  
  <p>However, I want to implement this with LINQ to Entities, not actual SQL. I would also prefer not to use stored procedures, and I don't want to do any sort of ToList/looping approach.</p>
  
  <p>Edit: Groups with more than the requested consecutive elements don't necessarily need to be split apart. i.e. in the previous example, a result of 9, 10, 11, 12 would also be acceptable.</p>