>>>>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.
>>
>>I'm sure you're right in that the processing time is minimal - but it still goes against the grain with me to waste a few milliseconds tho :-}
>>Did you see my update? If I can get a range of maybe 10-12 instead of 40,000 I'd go for it.....
>
>Yes now I saw and you are right:)
:-}
Just looked properly at your SampleWithEventList() - that is *really* nice LINQ !