Back to Devexpress

AppointmentCRUDEventArgs.AddToSource Property

wpf-devexpress-dot-xpf-dot-scheduling-dot-appointmentcrudeventargs-68003ff0.md

latest3.6 KB
Original Source

AppointmentCRUDEventArgs.AddToSource Property

Returns the list of appointments to add to the data source.

Namespace : DevExpress.Xpf.Scheduling

Assembly : DevExpress.Xpf.Scheduling.v25.2.dll

NuGet Package : DevExpress.Wpf.Scheduling

Declaration

csharp
public IReadOnlyList<AppointmentItem> AddToSource { get; }
vb
Public ReadOnly Property AddToSource As IReadOnlyList(Of AppointmentItem)

Property Value

TypeDescription
IReadOnlyList<AppointmentItem>

A list of DevExpress.Xpf.Scheduling.AppointmentItem objects that have been added to the scheduler.

|

Remarks

When a user updates or deletes a pattern, the scheduler deletes all ChangedOccurrence and DeletedOccurrence appointments for the corresponding recurring series. The Occurrence appointments are not stored in any collection to avoid a stack overflow for infinite recurring series. These appointments are automatically generated at runtime based on the pattern’s AppointmentItem.RecurrenceInfo property.

When the user modifies or deletes an Occurrence appointment, the scheduler adds the corresponding exception ( ChangedOccurrence or DeletedOccurrence ) to the AddToSource and Appointments lists.

The code snippet below adds appointments to the data source.

csharp
// 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));

        dbContext.SaveChanges();
    }
}
vb
' data context
Public Class SchedulingContext
    Inherits DbContext

    Public Sub New()
        MyBase.New(CreateConnection(), True)
    End Sub
    Private Shared Function CreateConnection() As DbConnection
        '...
    End Function
    Public Property AppointmentEntities() As DbSet(Of AppointmentEntity)
    Public Property ResourceEntities() As DbSet(Of ResourceEntity)
End Class

' save changes to the data source
Public Sub ProcessChanges(ByVal args As AppointmentCRUDEventArgs)
    Using dbContext = New SchedulingContext()
        dbContext.AppointmentEntities.AddRange(args.AddToSource.Select(Function(x) CType(x.SourceObject, AppointmentEntity)))

        dbContext.SaveChanges()
    End Using
End Sub

See Also

AppointmentCRUDEventArgs Class

AppointmentCRUDEventArgs Members

DevExpress.Xpf.Scheduling Namespace