次の方法で共有


SubmitOperation クラス

非同期送信操作を表します。

名前空間: System.ServiceModel.DomainServices.Client
アセンブリ: System.ServiceModel.DomainServices.Client (system.servicemodel.domainservices.client.dll 内)

使用方法

'使用
Dim instance As SubmitOperation

構文

'宣言
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

パラメーターとして SubmitOperation オブジェクトを受け取る OnSubmitCompleted という名前のコールバック メソッドの例を次に示します。このオブジェクトを使用してエラーがないか確認し、エラーを処理済みとしてマークします。

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

継承階層

System.Object
   System.ServiceModel.DomainServices.Client.OperationBase
    System.ServiceModel.DomainServices.Client.SubmitOperation

スレッド セーフ

この型の public static (Visual Basic では Shared) メンバーは、スレッド セーフです。インスタンス メンバーの場合は、スレッド セーフであるとは限りません。

プラットフォーム

開発プラットフォーム

Windows XP Home Edition, Windows XP Professional, Windows Server 2003 、Windows Server 2008、および Windows 2000

ターゲット プラットフォーム

Change History

参照

リファレンス

SubmitOperation のメンバー
System.ServiceModel.DomainServices.Client 名前空間