AppointmentCRUDEventArgs Class
The base class for CRUD (create, read, update, delete) events.
Namespace: DevExpress.Xpf.Scheduling
Assembly: DevExpress.Xpf.Scheduling.v24.1.dll
NuGet Package: DevExpress.Wpf.Scheduling
Declaration
Remarks
The code snippet below saves changes to the data source.
// data context
public class SchedulingContext : DbContext {
public SchedulingContext() : base(CreateConnection(), true) { }
static DbConnection CreateConnection() {
//...
}
public DbSet<AppointmentEntity> AppointmentEntities { get; set; }
public DbSet<ResourceEntity> ResourceEntities { get; set; }
}
// save changes to the data source
public void ProcessChanges(AppointmentCRUDEventArgs args) {
using(var dbContext = new SchedulingContext()) {
dbContext.AppointmentEntities.AddRange(args.AddToSource.Select(x => (AppointmentEntity)x.SourceObject));
foreach(var appt in args.UpdateInSource.Select(x => (AppointmentEntity)x.SourceObject))
AppointmentEntityHelper.CopyProperties(appt, dbContext.AppointmentEntities.Find(appt.Id));
foreach(var appt in args.DeleteFromSource.Select(x => (AppointmentEntity)x.SourceObject))
dbContext.AppointmentEntities.Remove(dbContext.AppointmentEntities.Find(appt.Id));
dbContext.SaveChanges();
}
}
Inheritance
See Also