Rule 列挙体とは? わかりやすく解説

Rule 列挙体

ForeignKeyConstraint を適用した場合実行されるアクション示します

名前空間: System.Data
アセンブリ: System.Data (system.data.dll 内)
構文構文

メンバメンバ
 メンバ説明
.NET Compact Framework によるサポートCascade関連行を削除または更新します。これは、既定設定です。 
.NET Compact Framework によるサポートNone関連行で何もアクション実行されません。 
.NET Compact Framework によるサポートSetDefault関連行の値を DefaultValue プロパティ格納されている値に設定します。 
.NET Compact Framework によるサポートSetNull関連行の値を DBNull に設定します。 
解説解説

Rule 値は、DataTable オブジェクトの ConstraintCollection 内に存在するForeignKeyConstraint オブジェクトの UpdateRule プロパティと DeleteRule プロパティ設定されます。

Rule 値は、列内の値を削除または更新したときに実行されるアクション決定します削除更新のうち、規則設定するときに重要で注意必要なのは、削除の方です。

値の削除場合Cascade は、その値が格納されている他のすべての行も削除することを指定します。SetNull は、すべての子列内の値が null 値設定されることを指定します。SetDefault は、すべての子列をその列の既定値設定することを指定します。None は、何もアクション実行せず、例外生成することを指定します

値の更新場合Cascade は、すべての子列も同様に新しい値で更新することを指定します。SetNull は、すべての子列を null 値設定することを指定します。SetDefault は、すべての子列の値を既定値設定することを指定します。None は、何もアクション実行せず、例外生成することを指定します

EnforceConstraints プロパティtrue場合除いては、DataSet対す制約適用されません。

AcceptChanges メソッド呼び出すと、AcceptRejectRule によって実行するアクション決定されます。

使用例使用例
' The next line goes into the Declarations section of the module:
' SuppliersProducts is a class derived from DataSet.
Private suppliersProducts As SuppliersProducts

Private Sub CreateConstraint()
    ' Declare parent column and child column variables.
    Dim parentColumn As DataColumn
    Dim childColumn As DataColumn
    Dim fkeyConstraint As ForeignKeyConstraint

    ' Set parent and child column variables.
    parentColumn = suppliersProducts.Tables("Suppliers").Columns("SupplierID")
    childColumn = suppliersProducts.Tables("Products").Columns("SupplierID")
    fkeyConstraint = New ForeignKeyConstraint( _
        "SupplierFKConstraint", parentColumn, childColumn)

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

    ' Add the constraint, and set EnforceConstraints to true.
    suppliersProducts.Tables("Products").Constraints.Add(fkeyConstraint)
    suppliersProducts.EnforceConstraints = True
End Sub
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Data 名前空間
DataTable.Constraints プロパティ
ForeignKeyConstraint クラス



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Rule 列挙体」の関連用語

Rule 列挙体のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Rule 列挙体のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS