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 09:34:19
 
 
À
19/06/2010 08:39:58
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Divers
Thread ID:
01469538
Message ID:
01469735
Vues:
24
>>>>>>I was going to do some ugly processing with loops, but I figured maybe Linq could help me out.
>>>>>>
>>>>>>RecurringEvents
>>>>>>ID (PK)
>>>>>>StartDate (datetime)
>>>>>>RecurrenceDays (int)
>>>>>>
>>>>>>How can I calculate which of these recurring events happen within a specified date range. Linq's gotta have some sexy method that will do this easily...
>>>>>
>>>>>Linq would surely have nice ways to have it but your layout seems very inadequate to me. For example what does RecurrenceDays stand for? Assuming it is the days that the event would be available continously from start:
>>>>>
>>>>>
var evList = from e in events
>>>>>  where e.StartDate <= end && e.StartDate.AddDays( e.RecurrenceDays ) >= start
>>>>>  select e;
>>>>>
>>>>>In method syntax:
>>>>>
>>>>>
var evList = events.Where( e => e.StartDate <= end && e.StartDate.AddDays( e.RecurrenceDays ) >= start);
>>>>>
>>>>>PS: You could also create extension methods in your say "ScheduleExtensions" namespace and simply use those methods for selection. It then might look like (assuming you created WithIn extension method for RecurringEvent that takes start, end parameters):
>>>>>
>>>>>
var evList = events.Where( e => e.WithIn( start, end ));
>>>>>
>>>>>Is there a setting somewhere to say that this is C# code and not VFP? Maybe class attribute or another tag?
>>>>>Cetin
>>>>
>>>>I'm open to a new layout, if you have a suggestion.
>>>
>>>iCalendar is the typical layout standard. I have done partial implementation in VFP and sooner or later I will need an enhanced version in C# myself:) One caveat I have seen is that also it is called a standard, it doesn't seem to be a standard and say outlook may return "unrecognized calendar format" to an icalendar format that is created by outlook:).
>>>Cetin
>>
>>Eh, I'm looking for something very simple. I may actually just give them a way to bulk insert dates into the db since it seems like it needs more flexibility that I originally thought.
>
>Yes that would be an option. Even though I support 'recurring' events in our application I too explicitly insert the event dates instead of recurrence definition.

I can't say I like that approach. Seems like you'd be swapping initial simplicity for a future maintenance nightmare....
How far ahead do you enter dates - and how do you ensure that they *are* entered far enough ahead....
At what point and how often do you remove past dates?
What happens if someone wants to change the definition of an event (e.g. change the interval or the stop date etc......)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform