DomainContext.RejectChanges-Methode
Setzt alle ausstehenden Änderungen für diesen DomainContext zurück.
Namespace: System.ServiceModel.DomainServices.Client
Assembly: System.ServiceModel.DomainServices.Client (in system.servicemodel.domainservices.client.dll)
Verwendung
'Usage
Dim instance As DomainContext
instance.RejectChanges
Syntax
'Declaration
Public Sub RejectChanges
public void RejectChanges ()
public:
void RejectChanges ()
public void RejectChanges ()
public function RejectChanges ()
Beispiel
Im folgenden Codebeispiel werden Methoden gezeigt, die die SubmitChanges-Methode und die RejectChanges-Methode aufrufen.
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();
}
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht sichergestellt.
Plattformen
Entwicklungsplattformen
Windows XP Home Edition, Windows XP Professional, Windows Server 2003 , Windows Server 2008 und Windows 2000
Zielplattformen
Change History
Siehe auch
Verweis
DomainContext-Klasse
DomainContext-Member
System.ServiceModel.DomainServices.Client-Namespace