Classe SubmitOperation
Représente une opération d'envoi asynchrone.
Espace de noms: System.ServiceModel.DomainServices.Client
Assembly : System.ServiceModel.DomainServices.Client (dans system.servicemodel.domainservices.client.dll)
Utilisation
'Utilisation
Dim instance As SubmitOperation
Syntaxe
'Déclaration
Public NotInheritable Class SubmitOperation
Inherits OperationBase
public sealed class SubmitOperation : OperationBase
public ref class SubmitOperation sealed : public OperationBase
public final class SubmitOperation extends OperationBase
public final class SubmitOperation extends OperationBase
Exemple
L'exemple suivant illustre une méthode de rappel nommée OnSubmitCompleted
qui accepte comme paramètre un objet SubmitOperation. Il utilise cet objet pour rechercher des erreurs et les marquer comme étant gérées.
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();
}
Hiérarchie d'héritage
System.Object
System.ServiceModel.DomainServices.Client.OperationBase
System.ServiceModel.DomainServices.Client.SubmitOperation
Sécurité des threads
Tous les membres publics statiques (Partagés dans Visual Basic) de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.
Plateformes
Plateformes de développement
Windows XP Édition familiale, Windows XP Professionnel, Windows Server 2003 , Windows Server 2008 et Windows 2000
Plateformes cibles
Change History
Voir aussi
Référence
Membres SubmitOperation
Espace de noms System.ServiceModel.DomainServices.Client