I am receiving the following error when attempting to call ScheduleViewRepository.Context.SubmitChanges() when I have removed an appointment from the ScheduleView:
"Submit operation failed. An error occurred while updating the entries. See the inner exception for details. InnerException message: The DELETE statement conflicted with the REFERENCE constraint \"FK_SqlAppointmentResources_SqlAppointment\". The conflict occurred in database \"ScheduleView\", table \"dbo.SqlAppointmentResources\", column 'SqlAppointments_SqlAppointmentId'.\r\nThe statement has been terminated."
Am I missing a method call?
Here is the code that is being called when saving the schedule:
"Submit operation failed. An error occurred while updating the entries. See the inner exception for details. InnerException message: The DELETE statement conflicted with the REFERENCE constraint \"FK_SqlAppointmentResources_SqlAppointment\". The conflict occurred in database \"ScheduleView\", table \"dbo.SqlAppointmentResources\", column 'SqlAppointments_SqlAppointmentId'.\r\nThe statement has been terminated."
Am I missing a method call?
Here is the code that is being called when saving the schedule:
private void OnSaveCommandExecute(object param)
{
if (ScheduleViewRepository.Context.HasChanges)
{
try
{
ScheduleViewRepository.Context.SubmitChanges().Completed += (s, a) =>
{
while (ScheduleViewRepository.DeletedAppointments.Count > 0)
{
ScheduleViewRepository.Context.SqlAppointments.Remove(ScheduleViewRepository.DeletedAppointments.Dequeue());
}
ScheduleViewRepository.Context.SubmitChanges(); // This is the line that fails
};
}
catch (System.Exception)
{
throw;
}
}
}