DataSource.FetchTimeRegions Event
Allows you to load time regions only for the specified date range.
Namespace: DevExpress.Xpf.Scheduling
Assembly: DevExpress.Xpf.Scheduling.v24.2.dll
NuGet Package: DevExpress.Wpf.Scheduling
#Declaration
#Event Data
The FetchTimeRegions event's data class is FetchDataEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Async |
Gets or sets a task that allows you to fetch data asynchronously in the Scheduler |
Cancellation |
Gets an object that notifies that the current data load has been cancelled during the asynchronous data fetch. The Cancellation |
Ids |
Returns the identifiers of scheduler items that have been reloaded by the Reload |
Interval | Returns the time range for which to fetch the scheduler items. |
Result | Specifies the list of scheduler items to load from the data source. |
The event data class exposes the following methods:
Method | Description |
---|---|
Get |
Generates an expression that you can use to obtain appointments from the data source. |
Is |
Determines whether a specified interval is visible in the Scheduler |
#Remarks
Specify TimeRegionMappings.QueryStart and TimeRegionMappings.QueryEnd mappings to handle the FetchTimeRegions
event.
These mappings allow you to calculate the correct interval that is used in a SELECT query when you handle the FetchTimeRegions
event.
The use of the TimeRegionMappings.Start and TimeRegionMappings.End properties is not recommended in this scenario because such an interval may not include time region patterns and the corresponding exceptions.
The example below illustrates how to fetch time regions from a DbContext
source. The FetchMode property is set to Bound
.
public class SchedulingDataContext : DbContext {
public SchedulingDataContext() : base(CreateConnection(), true) { }
static DbConnection CreateConnection() {
//...
}
public DbSet<TimeRegionEntity> TimeRegionEntities { get; set; }
//...
}
private void dataSource_FetchTimeRegions(object sender, DevExpress.Xpf.Scheduling.FetchDataEventArgs e) {
using (var dbContext = new SchedulingDataContext()) {
e.AsyncResult = dbContext.TimeRegionEntities
.Where(x => x.QueryStart <= e.Interval.End
&& x.QueryEnd >= e.Interval.Start)
.ToArrayAsync();
}
}
The FetchRange property specifies the time interval for which to fetch the time regions. FetchTimeRegion
loads items for the SchedulerControl.VisibleIntervals extended up to the FetchRange
.
Refer to this topic for more information: Load Data on Demand.