AcceptRejectRule Wyliczenie

Definicja

Określa akcję, która występuje, gdy AcceptChanges() metoda lub RejectChanges() jest wywoływana na obiekcie DataTable z elementem ForeignKeyConstraint.

C#
public enum AcceptRejectRule
Dziedziczenie
AcceptRejectRule

Pola

Nazwa Wartość Opis
Cascade 1

Zmiany są kaskadowe w relacji.

None 0

Nie występuje żadna akcja (wartość domyślna).

Przykłady

Poniższy przykład tworzy obiekt ForeignKeyConstraint, ustawia różne jego właściwości, w tym AcceptRejectRuleelement , i dodaje go do DataTable obiektu ConstraintCollection.

C#
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;
}

Uwagi

Zmiany w obiekcie DataTable nie są ostateczne, dopóki nie wywołasz AcceptChanges metody . Gdy element AcceptChanges lub RejectChanges jest wywoływany w wierszu w tabeli nadrzędnej, wartość określa, AcceptRejectRule czy zmiany są propagowane do odpowiednich wierszy w tabeli podrzędnej.

Dotyczy

Produkt Wersje
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Zobacz też