Export (0) Print
Expand All

OperationBase.MarkErrorAsHandled Method

WCF RIA Services

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Specifies that an error encountered in an operation is handled.

Namespace:  System.ServiceModel.DomainServices.Client
Assembly:  System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)

public void MarkErrorAsHandled()

ExceptionCondition
InvalidOperationException

The HasError property is false.

You call this method when you have taken the required steps to recover from an error in a domain operation. By calling this method, you indicate that the error will not be thrown as an exception. If this method is not called for a failed operation, the exception specified in the Complete method will be thrown.

The System#ComponentModel#INotifyPropertyChanged#PropertyChanged() event is raised for the IsErrorHandled property.

The following example shows a callback method for a submit operation that checks for errors and calls the MarkErrorAsHandled method.

private void SaveButton_Click(object sender, RoutedEventArgs e)
{
    _customerContext.SubmitChanges(OnSubmitCompleted, null);
}

private void RejectButton_Click(object sender, RoutedEventArgs e)
{
    _customerContext.RejectChanges();
    CheckChanges();
}

private void CustomerGrid_RowEditEnded(object sender, DataGridRowEditEndedEventArgs e)
{
    CheckChanges();
}

private void CheckChanges()
{
    EntityChangeSet changeSet = _customerContext.EntityContainer.GetChanges();
    ChangeText.Text = changeSet.ToString();

    bool hasChanges = _customerContext.HasChanges;
    SaveButton.IsEnabled = hasChanges;
    RejectButton.IsEnabled = hasChanges;
}

private void OnSubmitCompleted(SubmitOperation so)
{
    if (so.HasError)
    {
        MessageBox.Show(string.Format("Submit Failed: {0}", so.Error.Message));
        so.MarkErrorAsHandled();
    }
    CheckChanges();
}


Show:
© 2014 Microsoft