ForeignKeyConstraint 클래스

정의

값 또는 행이 삭제되거나 업데이트될 때 기본 키/외래 키 관계에서 열 집합에 적용되는 동작 제한을 나타냅니다.

public ref class ForeignKeyConstraint : System::Data::Constraint
public class ForeignKeyConstraint : System.Data.Constraint
[System.Serializable]
public class ForeignKeyConstraint : System.Data.Constraint
type ForeignKeyConstraint = class
    inherit Constraint
[<System.Serializable>]
type ForeignKeyConstraint = class
    inherit Constraint
Public Class ForeignKeyConstraint
Inherits Constraint
상속
ForeignKeyConstraint
특성

예제

다음 예제에서는 을 ForeignKeyConstraint만들고 해당 속성 중 일부를 설정하고 개체의 ConstraintCollectionDataTable 추가합니다.

' 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

설명

ForeignKeyConstraint 열(또는 열)의 값이 삭제되거나 업데이트될 때 수행되는 작업을 제한합니다. 이러한 제약 조건은 기본 키 열과 함께 사용됩니다. 두 테이블 간의 부모/자식 관계에서 부모 테이블에서 값을 삭제하면 다음 방법 중 하나로 자식 행에 영향을 줄 수 있습니다.

  • 자식 행을 삭제할 수도 있습니다(연속 작업).

  • 자식 열(또는 열)의 값을 null 값으로 설정할 수 있습니다.

  • 자식 열(또는 열)의 값을 기본값으로 설정할 수 있습니다.

  • 예외를 생성할 수 있습니다.

ForeignKeyConstraint개체는 속성을 통해 Constraints 액세스되는 의 DataTableConstraintCollection 포함됩니다.

속성이 로 설정true되지 않으면 EnforceConstraints 제약 조건이 적용되지 않습니다.

개체 AcceptRejectRuleAcceptChanges 메서드가 DataTable 호출될 때마다 가 적용됩니다.

생성자

ForeignKeyConstraint(DataColumn, DataColumn)

지정된 부모 및 자식 ForeignKeyConstraint 개체를 사용하여 DataColumn 클래스의 새 인스턴스를 초기화합니다.

ForeignKeyConstraint(DataColumn[], DataColumn[])

부모와 자식 ForeignKeyConstraint 개체의 지정된 배열을 사용하여 DataColumn 클래스의 새 인스턴스를 초기화합니다.

ForeignKeyConstraint(String, DataColumn, DataColumn)

지정된 이름, 부모 및 자식 ForeignKeyConstraint 개체를 사용하여 DataColumn 클래스의 새 인스턴스를 초기화합니다.

ForeignKeyConstraint(String, DataColumn[], DataColumn[])

지정된 이름, 부모와 자식 ForeignKeyConstraint 개체의 배열을 사용하여 DataColumn 클래스의 새 인스턴스를 초기화합니다.

ForeignKeyConstraint(String, String, String, String[], String[], AcceptRejectRule, Rule, Rule)

이 생성자는 Visual Studio 환경에서 디자인 타임 지원을 위해 제공됩니다. 이 생성자를 사용하여 만든 ForeignKeyConstraint 개체는 AddRange(Constraint[])를 통해 컬렉션에 추가해야 합니다. 메서드가 호출될 때, 지정된 이름을 가진 테이블과 열이 있어야 합니다. 이 생성자를 호출하기 전에 BeginInit()이 호출된 경우, 지정된 이름을 가진 테이블과 열이 EndInit()이 호출될 때 있어야 합니다.

ForeignKeyConstraint(String, String, String[], String[], AcceptRejectRule, Rule, Rule)

이 생성자는 Visual Studio 환경에서 디자인 타임 지원을 위해 제공됩니다. 이 생성자를 사용하여 만든 ForeignKeyConstraint 개체는 AddRange(Constraint[])를 통해 컬렉션에 추가해야 합니다. 메서드가 호출될 때, 지정된 이름을 가진 테이블과 열이 있어야 합니다. 이 생성자를 호출하기 전에 BeginInit()이 호출된 경우, 지정된 이름을 가진 테이블과 열이 EndInit()이 호출될 때 있어야 합니다.

속성

_DataSet

이 제약 조건이 속한 DataSet를 가져옵니다.

(다음에서 상속됨 Constraint)
AcceptRejectRule

AcceptChanges()가 호출될 때 이 제약 조건에서 발생하게 될 동작을 나타냅니다.

Columns

이 제약 조건의 자식 열을 가져옵니다.

ConstraintName

ConstraintCollection의 제약 조건 이름입니다.

(다음에서 상속됨 Constraint)
DeleteRule

행이 삭제될 때 이 제약 조건에 발생하는 동작을 가져오거나 설정합니다.

ExtendedProperties

사용자 정의 제약 조건 속성 컬렉션을 가져옵니다.

(다음에서 상속됨 Constraint)
RelatedColumns

이 제약 조건의 부모 열입니다.

RelatedTable

이 제약 조건의 부모 테이블을 가져옵니다.

Table

이 제약 조건의 자식 테이블을 가져옵니다.

UpdateRule

행이 업데이트될 때 이 제약 조건에 발생하는 동작을 가져오거나 설정합니다.

메서드

CheckStateForProperty()

이 제약 조건이 속한 DataSet를 가져옵니다.

(다음에서 상속됨 Constraint)
Equals(Object)

현재 ForeignKeyConstraint가 지정된 개체와 같은지 여부를 나타내는 값을 가져옵니다.

GetHashCode()

ForeignKeyConstraint 개체의 이 인스턴스의 해시 코드를 가져옵니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
SetDataSet(DataSet)

제약 조건의 DataSet을 설정합니다.

(다음에서 상속됨 Constraint)
ToString()

ConstraintName이 있는 경우 문자열로 가져옵니다.

(다음에서 상속됨 Constraint)

적용 대상

스레드 보안

이 형식은 다중 스레드 읽기 작업에 안전합니다. 모든 쓰기 작업을 동기화해야 합니다.

추가 정보