>Hi,
>Cool. But aren't you checking too many possible occurences. In SampleWithSingleEvent():
>int days = (new int[] { (end - e.StartDate).Days, 0 }).Max();
>//could be just?:
>int days = (end - e.StartDate).Days / e.RecurrenceDays;
>But still could be a lot of wasted calculations if the StartDate is way earlier than the range start ?
While that is true I didn't go deeper to optimize it and trusted Linq's lazy evaluation. In real world applications likely day count would be less than 100 years * 366 = 36600 which is nothing to calculate for Linq. Range() is the cool method there providing a 'Tally table' where mortal T-SQL coders need to create themselves. Out of curiosity I just tested with 40000 days and on my old AMD Turion 64 MK-36 1 Gb RAM notebook it completes to create the dates list in 8-16 milliseconds.
Cetin