SubmitOperation Class
[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.]
Represents an asynchronous submit operation.
Inheritance Hierarchy
System.Object
System.ServiceModel.DomainServices.Client.OperationBase
System.ServiceModel.DomainServices.Client.SubmitOperation
Namespace: System.ServiceModel.DomainServices.Client
Assembly: System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)
Syntax
'Declaration
Public NotInheritable Class SubmitOperation _
Inherits OperationBase
'Usage
Dim instance As SubmitOperation
public sealed class SubmitOperation : OperationBase
public ref class SubmitOperation sealed : public OperationBase
[<SealedAttribute>]
type SubmitOperation =
class
inherit OperationBase
end
public final class SubmitOperation extends OperationBase
The SubmitOperation type exposes the following members.
Properties
Name | Description | |
---|---|---|
CanCancel | Gets a value that indicates whether this OperationBase is currently in a state that enables it to be canceled. (Inherited from OperationBase.) | |
ChangeSet | Gets change set being submitted. | |
EntitiesInError | Gets any entities that have errors after the submit operation completes. | |
Error | Gets the operation error if the operation failed. (Inherited from OperationBase.) | |
HasError | Gets a value that indicates whether the operation failed. (Inherited from OperationBase.) | |
IsCanceled | Gets a value that indicates whether this operation has been canceled. (Inherited from OperationBase.) | |
IsComplete | Gets a value that indicates whether this operation has completed. (Inherited from OperationBase.) | |
IsErrorHandled | Gets or sets a value that indicates whether the operation error has been handled. (Inherited from OperationBase.) | |
Result | Gets the result of the asynchronous operation. (Inherited from OperationBase.) | |
SupportsCancellation | Gets a value that indicates whether this operation supports cancellation. (Inherited from OperationBase.) | |
UserState | Gets the optional user state for this operation. (Inherited from OperationBase.) |
Top
Methods
Name | Description | |
---|---|---|
Cancel | Cancels the operation. (Inherited from OperationBase.) | |
CancelCore | When overridden in a derived class, provides the logic to cancel the operation. (Inherited from OperationBase.) | |
Complete(Exception) | Completes a failed operation with the specified error. (Inherited from OperationBase.) | |
Complete(Object) | Completes a successful operation with the specified result. (Inherited from OperationBase.) | |
Equals | (Inherited from Object.) | |
Finalize | (Inherited from Object.) | |
GetHashCode | (Inherited from Object.) | |
GetType | (Inherited from Object.) | |
InvokeCompleteAction | Invokes the completion callback. (Inherited from OperationBase.) | |
MarkErrorAsHandled | Specifies that an error encountered in an operation is handled. (Inherited from OperationBase.) | |
MemberwiseClone | (Inherited from Object.) | |
OnPropertyChanged | Called when the value of a property changes. (Inherited from OperationBase.) | |
RaisePropertyChanged | Raises the System#ComponentModel#INotifyPropertyChanged#PropertyChanged() event. (Inherited from OperationBase.) | |
ToString | (Inherited from Object.) |
Top
Events
Name | Description | |
---|---|---|
Completed | Occurs when the operation completes. (Inherited from OperationBase.) |
Top
Explicit Interface Implementations
Name | Description | |
---|---|---|
INotifyPropertyChanged.PropertyChanged | Occurs when a property value changes. (Inherited from OperationBase.) |
Top
Examples
The following example shows a callback method named OnSubmitCompleted that accepts a SubmitOperation object as a parameter. It uses this object to check for errors and mark the errors as handled.
Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
_customerContext.SubmitChanges(AddressOf OnSubmitCompleted, Nothing)
End Sub
Private Sub RejectButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
_customerContext.RejectChanges()
CheckChanges()
End Sub
Private Sub CustomerGrid_RowEditEnded(ByVal sender As System.Object, ByVal e As System.Windows.Controls.DataGridRowEditEndedEventArgs)
CheckChanges()
End Sub
Private Sub CheckChanges()
Dim changeSet = _customerContext.EntityContainer.GetChanges()
ChangeText.Text = changeSet.ToString()
Dim hasChanges = _customerContext.HasChanges
SaveButton.IsEnabled = hasChanges
RejectButton.IsEnabled = hasChanges
End Sub
Private Sub OnSubmitCompleted(ByVal so As SubmitOperation)
If (so.HasError) Then
MessageBox.Show(String.Format("Submit Failed: {0}", so.Error.Message))
so.MarkErrorAsHandled()
End If
CheckChanges()
End Sub
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();
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.