DomainContext.SubmitChanges Method (Action<SubmitOperation>, Object)

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.]

Submits all pending changes to the domain service.

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

public virtual SubmitOperation SubmitChanges(
	Action<SubmitOperation> callback,
	Object userState


Type: System.Action<SubmitOperation>
Optional callback for the submit operation.
Type: System.Object
Optional user state to associate with the operation.

Return Value

Type: System.ServiceModel.DomainServices.Client.SubmitOperation
The submit operation.

You use the SubmitChanges method to update, insert, or delete data. All of the pending changes are submitted in one operation. You provide a callback method when you have code that must execute after the asynchronous operation has finished. In the callback method, you can check for errors and update the user interface as needed.

The following code example shows methods that call the SubmitChanges and RejectChanges methods.

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

private void RejectButton_Click(object sender, RoutedEventArgs e)

private void CustomerGrid_RowEditEnded(object sender, DataGridRowEditEndedEventArgs e)

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