AcceptRejectRule AcceptRejectRule AcceptRejectRule AcceptRejectRule Enum

定義

ForeignKeyConstraint が設定されている DataTableAcceptChanges() メソッドまたは RejectChanges() メソッドを呼び出した場合に実行されるアクションを決定します。Determines the action that occurs when the AcceptChanges() or RejectChanges() method is invoked on a DataTable with a ForeignKeyConstraint.

public enum class AcceptRejectRule
public enum AcceptRejectRule
type AcceptRejectRule = 
Public Enum AcceptRejectRule
継承
AcceptRejectRuleAcceptRejectRuleAcceptRejectRuleAcceptRejectRule

フィールド

Cascade Cascade Cascade Cascade 1

リレーションシップ全体に連鎖変更が行われます。Changes are cascaded across the relationship.

None None None None 0

アクションは実行されません (既定値)。No action occurs (default).

次の例ではForeignKeyConstraint、を作成し、をAcceptRejectRule含むさまざまなプロパティを設定DataTableし、それをオブジェクトConstraintCollectionのに追加します。The following example creates a ForeignKeyConstraint, sets various of its properties, including the AcceptRejectRule, and adds it to a DataTable object's ConstraintCollection.

private void CreateConstraint(DataSet dataSet, 
    string table1, string table2,string column1, string column2)
{
   // Declare parent column and child column variables.
   DataColumn parentColumn;
   DataColumn childColumn;
   ForeignKeyConstraint foreignKeyConstraint;

   // Set parent and child column variables.
   parentColumn = dataSet.Tables[table1].Columns[column1];
   childColumn = dataSet.Tables[table2].Columns[column2];
   foreignKeyConstraint = new ForeignKeyConstraint
      ("SupplierForeignKeyConstraint",  parentColumn, childColumn);

   // Set null values when a value is deleted.
   foreignKeyConstraint.DeleteRule = Rule.SetNull;
   foreignKeyConstraint.UpdateRule = Rule.Cascade;
   foreignKeyConstraint.AcceptRejectRule = AcceptRejectRule.None;

   // Add the constraint, and set EnforceConstraints to true.
   dataSet.Tables[table1].Constraints.Add(foreignKeyConstraint);
   dataSet.EnforceConstraints = true;
}
Private Sub CreateConstraint(dataSet As DataSet, _
   table1 As String, table2 As String, _
   column1 As String, column2 As String)

   ' Declare parent column and child column variables.
   Dim parentColumn As DataColumn
   Dim childColumn As DataColumn
   Dim foreignKeyConstraint As ForeignKeyConstraint

   ' Set parent and child column variables.
   parentColumn = dataSet.Tables(table1).Columns(column1)
   childColumn = dataSet.Tables(table2).Columns(column2)
   foreignKeyConstraint = New ForeignKeyConstraint _
      ("SupplierForeignKeyConstraint", parentColumn, childColumn)

   ' Set null values when a value is deleted.
   foreignKeyConstraint.DeleteRule = Rule.SetNull
   foreignKeyConstraint.UpdateRule = Rule.Cascade
   foreignKeyConstraint.AcceptRejectRule = AcceptRejectRule.None

   ' Add the constraint, and set EnforceConstraints to true.
   dataSet.Tables(table1).Constraints.Add(foreignKeyConstraint)
   dataSet.EnforceConstraints = True
End Sub

注釈

に対する変更DataTableは、 AcceptChangesメソッドを呼び出すまで最後ではありません。Changes to a DataTable are not final until you call the AcceptChanges method. 親テーブルRejectChangesの行でAcceptChangesまたはが呼び出されると、子テーブルの対応する行に変更が反映されるかどうかが値によって決まります。AcceptRejectRuleWhen either AcceptChanges or RejectChanges is called on a row in the parent table, the AcceptRejectRule value determines whether or not changes are propagated to corresponding rows in the child table.

適用対象

こちらもご覧ください