title: Get a range of dates given an interval and step
body: <p><strong>Edit</strong>
  It looks like creating a table that holds the DateTimes by minutes to join against would make the most sense. 100 years worth of minutes is ~52M rows. Indexed by the Ticks should make the query run pretty fast. It now becomes</p>
  
  <p>Thanks for the feedback everyone!</p>
  
  <p>I have a class called Recurrence that looks like this:</p>
  
  <pre><code>public class Recurrence
  {
      public int Id { get; protected set; }
      public DateTime StartDate { get; protected set; }
      public DateTime? EndDate { get; protected set; }
      public long? RecurrenceInterval { get; protected set; }
  
  }
  </code></pre>
  
  <p>It is an entity framework POCO class. There are two things I want to do with this class all with standard query operators. (So that the query runs entirely server side).</p>
  
  <p>First I want to create a query that returns all the dates from the start date to the end date inclusive with the given recurrence interval. The iterative function is simple</p>
  
  <pre><code>for(i=StartDate.Ticks; i&lt;=EndDate.Ticks; i+=RecurrenceInterval)
  {
    yield return new DateTime(i);
  }
  </code></pre>
  
  <p>Enumerable.Range() would be an option but there is no long version of Range. I'm thinking my only option here is Aggregate but I'm still not very strong with that function.</p>
  
  <p>Finally once I have that query working, I want to return the values from there that are within a time window i.e. between a different start and end date. That is easy enough to do using SkipWhile/TakeWhile.</p>
  
  <p>Here's how I could do it if DateTime.Ticks was an int</p>
  
  <pre><code>from recurrence in Recurrences
  let range =
  Enumerable
    .Range(
      (int)recurrence.StartDate.Ticks,
      recurrence.EndDate.HasValue ? (int)recurrence.EndDate.Value.Ticks : (int)end.Ticks)
    .Where(i=&gt;i-(int)recurrence.StartDate.Ticks%(int)recurrence.RecurrenceLength.Value==0)
    .SkipWhile(d =&gt; d &lt; start.Ticks)
    .TakeWhile(d =&gt; d &lt;= end.Ticks)
  from date in range
  select new ScheduledEvent { Date = new DateTime(date) };
  </code></pre>
  
  <p>I guess what I need is an implementation of LongRange that could execute over an EF Query.</p>