Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could create your own date range method</p> <pre><code>public static class EnumerableEx { public static IEnumerable&lt;DateTime&gt; DateRange(DateTime startDate, DateTime endDate, TimeSpan intervall) { for (DateTime d = startDate; d &lt;= endDate; d += intervall) { yield return d; } } } </code></pre> <p>Then query with</p> <pre><code>var query = from recurrence in Recurrences from date in EnumerableEx.DateRange(recurrence.StartDate, recurrence.EndDate ?? end, recurrence.RecurrenceInterval) select new ScheduledEvent { Date = date }; </code></pre> <p>This assumes that <code>RecurrenceInterval</code> is declared as <code>TimeSpan</code> and <code>end</code> as <code>DateTime</code>.</p> <hr> <p>EDIT: Would this version restrict the recurrences on the server side as you excpect?</p> <pre><code>var query = from recurrence in Recurrences where recurrence.StartDate &lt;= end &amp;&amp; (recurrence.EndDate != null &amp;&amp; recurrence.EndDate.Value &gt;= start || recurrence.EndDate == null) from date in EnumerableEx.DateRange( recurrence.StartDate, recurrence.EndDate.HasValue &amp;&amp; recurrence.EndDate.Value &lt; end ? recurrence.EndDate.Value : end, recurrence.RecurrenceInterval) where (date &gt;= start) select new ScheduledEvent { Date = date }; </code></pre> <p>Here the returned recurrences already take in account the <code>start</code> and the <code>end</code> date, thus not returning obsolete recurrences. <code>EnumerableEx.DateRange</code> has no effect on the first part of the query.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload