This is a migrated thread and some comments may be shown as answers.

Parsing RecurrenceRule

4 Answers 173 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
GrZeCh
Top achievements
Rank 2
GrZeCh asked on 01 Aug 2008, 03:40 PM
Hello!

Does someone tryed to parse RecurrenceRule? I'm binding RadScheduler to List (example: http://www.telerik.com/DEMOS/ASPNET/Prometheus/Scheduler/Examples/BindToList/DefaultCS.aspx) generated by LINQ 2 SQL and as an addon to calendar I want to have upcoming events list (lets say 2 weeks ahead or maybe showing next 5 events). There is no problems with events which have no recurrency but how to parse appointments which are recurrent? Any ideas?

Thanks

4 Answers, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 04 Aug 2008, 01:08 PM
Hi,

Please, take a look at the following forum thread:
http://www.telerik.com/community/forums/thread/b311D-bettda.aspx

You should be able to use the managed UDF in your LINQ queries.

All the best,
Tsvetomir Tsonev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
GrZeCh
Top achievements
Rank 2
answered on 04 Aug 2008, 06:01 PM
Great. Thanks. This is what I was looking for. If You are intertested I've managed to transform DLL files to SQL query (of course content is encoded but is easier to add this to SQL Server - no uploading DLL files).
0
GrZeCh
Top achievements
Rank 2
answered on 04 Aug 2008, 06:49 PM
I'm writing You my LINQ query which I'm using to retrieve 2 closest recurring events from DB (CROSS APPLY):

            myDataClassesDataContext context = new myDataClassesDataContext(); 
            var query = 
                (context.evr_calendars.SelectMany( 
                    calendars => 
                    context.ExpandRecurrence(calendars.RecurrenceRule, DateTime.Parse("2007-01-01 01:01:01"), 
                                             DateTime.Parse("2017-01-01 01:01:01")), (calendars, recurrence) => new 
                                                                                                                    { 
                                                                                                                        ID = calendars.id_calendar, 
                                                                                                                        Subject = calendars.subject, 
                                                                                                                        Start = recurrence.StartDate ?? calendars.startdate, 
                                                                                                                        End = recurrence.EndDate ?? calendars.enddate 
                                                                                                                    })).Take(2); 

Here is OUTER APPLY in LINQ (taking 5 items from one year ahead):

            var query2 = (context.evr_calendars.SelectMany( 
                calendars => context.ExpandRecurrence(calendars.RecurrenceRule, DateTime.Now, DateTime.Now.AddYears(1)).DefaultIfEmpty(), 
                (calendars, recurrences) => new 
                                                { 
                                                    ID = calendars.id_calendar, 
                                                    Subject = calendars.subject, 
                                                    Start = recurrences.StartDate ?? calendars.startdate, 
                                                    End = recurrences.EndDate ?? calendars.enddate 
                                                })).OrderBy(calendars => calendars.Start).Take(5); 

0
T. Tsonev
Telerik team
answered on 05 Aug 2008, 07:28 AM
Hi,

I am glad that the we have managed to help you. Thank you for posting the LINQ samples.

Sincerely yours,
Tsvetomir Tsonev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Scheduler
Asked by
GrZeCh
Top achievements
Rank 2
Answers by
T. Tsonev
Telerik team
GrZeCh
Top achievements
Rank 2
Share this question
or