DomainContext.RejectChanges 方法
针对该 DomainContext 恢复所有挂起的更改。
命名空间: System.ServiceModel.DomainServices.Client
程序集: System.ServiceModel.DomainServices.Client(在 system.servicemodel.domainservices.client.dll 中)
用法
用法
Dim instance As DomainContext
instance.RejectChanges
语法
声明
Public Sub RejectChanges
public void RejectChanges ()
public:
void RejectChanges ()
public void RejectChanges ()
public function RejectChanges ()
示例
下面的代码示例演示了调用 SubmitChanges 和 RejectChanges 的方法。
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();
}
线程安全
此类型的任何公共静态(在 Visual Basic 中为 共享)成员都是线程安全的。不保证所有实例成员都是线程安全的。
平台
开发平台
Windows XP Home Edition, Windows XP Professional, Windows Server 2003 、Windows Server 2008 和 Windows 2000
目标平台
Change History
另请参见
参考
DomainContext 类
DomainContext 成员
System.ServiceModel.DomainServices.Client 命名空间