public void DiscardChanges(UnitOfWork unitOfWork, XPBaseCollection collection) { var deletedTLObjects = TransactionalChangeHandler.GetDeletedTLObjects <RoomBooking>(unitOfWork); foreach (var newObject in TransactionalChangeHandler.GetSavedNewObjects(unitOfWork)) { TransactionalChangeHandler.ResetAssociations(newObject); // special behavior for this form if (newObject is RoomBooking) { // remove the appointment from the collection, this doesn't // happen automatically var appt = schedulerStorage.Appointments.Items.Find( a => object.ReferenceEquals(a.GetRow(schedulerStorage), newObject)); schedulerStorage.Appointments.Remove(appt); } } unitOfWork.ReloadChangedObjects(); // special behavior: get the right collection first var roomBookingCollection = (IList <RoomBooking>)schedulerStorage.Appointments.DataSource; foreach (var item in deletedTLObjects) { roomBookingCollection.Add(item); } }