Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to handle FetchAppointments event when the Scheduler is bound to the Entity Framework datasource

$
0
0

The SchedulerStorageBase.FetchAppointments Event event allows you to limit the number of appointments fetched from the data source. This can be useful when working with a large amount of data, and only a small part of it needs to be loaded at one time. 


Please pay special attention to managing recurring appointments. A recurring appointment series is never stored in the underlying data source. The data source only contains records for the pattern, and changed and deleted appointments. Once you change or delete any appointment from that series, a new appointment is created with a corresponding Appointment.Type - AppointmentType.ChangedOccurrence (value = 3) or AppointmentType.DeletedOccurrence (value = 4 ), and this appointment is stored in the data source as a separate record. 

The SchedulerControl generates recurring series with occurrences based on the pattern's recurring rule and removes deleted and changed occurrences from the chain. However, if the changed occurrence is moved outside of the queryable time range, it is not loaded and the SchedulerControl will generate an occurrence with the corresponding recurrence index instead of this (non-loaded) changed occurrence. 

To handle this situation, it is possible to load all changed occurrences despite their Start and End property values or implement two additional appointment custom fields to store original occurrence's Start and End values. The latter approach is demonstrated in this example.

 

Please note that prior to v.15.2, the FetchAppointments event occurs in situations, which do not involve any changes in displayed data ranges. This behavior may result in unhandled exceptions if the event was not properly handled. To solve the problem, we have implemented additional internal criteria that should be met before the event is raised. Starting with v.15.2, the FetchAppointments event fires not as often as it did before and does not fire at all in certain situations. If you experience unwanted side effects due to the newly introduced behavior, set the EnableSmartFetch option to false to revert to the former mechanism of raising the FetchAppointments event.

This example uses the "Database First" Entity Framework approach. To test the project locally, set up the CarsXtraScheduling sample database in your SQL Server instance. This database script is included along with the attached solution. 

See Also:

 Create the First simple Entity Data Model

Question Comments

Added By: SamDev at: 7/18/2016 11:46:19 AM    

where entity.EventType == 1 || (entity.StartTime < lastFetchedInterval.End && entity.EndTime > lastFetchedInterval.Start)
For anyone following this example the above code does not work when changed appointments are moved out of the range your looking at.  You need to load not just all patterns but changed appointments.  In another post I warn about this issue.  The changed appointments if within the range being viewed will show up properly.  If out of the range it will seem as is you never have a changed appointment at all  !!
Added By: Yulia (DevExpress Support) at: 7/18/2016 12:43:51 PM    Hello,

Thank you for pointing this out. We will correct the example accordingly.

Viewing all articles
Browse latest Browse all 7205

Trending Articles