Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculating which recurring events happen in a date rang
Message
De
19/06/2010 13:10:58
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
19/06/2010 12:22:17
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Divers
Thread ID:
01469538
Message ID:
01469751
Vues:
19
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform