ForeignKeyConstraint 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
값 또는 행이 삭제되거나 업데이트될 때 기본 키/외래 키 관계의 열 집합에 적용되는 작업 제한을 나타냅니다.
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개체ConstraintCollection에 추가 DataTable 합니다.
' 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개체는 속성을 통해 액세스되는 개체의 DataTable개체에 Constraints 포함 ConstraintCollection 됩니다.
속성이 .로 설정true되지 않으면 EnforceConstraints 제약 조건이 적용되지 않습니다.
개체 AcceptRejectRule 의 AcceptChanges 메서드가 DataTable 호출될 때마다 적용됩니다.
생성자
속성
| Name | Description |
|---|---|
| _DataSet |
이 제약 조건이 DataSet 속한 값을 가져옵니다. (다음에서 상속됨 Constraint) |
| AcceptRejectRule |
호출될 때 AcceptChanges() 이 제약 조건에서 수행해야 하는 작업을 나타냅니다. |
| Columns |
이 제약 조건의 자식 열을 가져옵니다. |
| ConstraintName |
에 있는 ConstraintCollection제약 조건의 이름입니다. (다음에서 상속됨 Constraint) |
| DeleteRule |
행이 삭제될 때 이 제약 조건에서 발생하는 작업을 가져오거나 설정합니다. |
| ExtendedProperties |
사용자 정의 제약 조건 속성의 컬렉션을 가져옵니다. (다음에서 상속됨 Constraint) |
| RelatedColumns |
이 제약 조건의 부모 열입니다. |
| RelatedTable |
이 제약 조건의 부모 테이블을 가져옵니다. |
| Table |
이 제약 조건의 자식 테이블을 가져옵니다. |
| UpdateRule |
행이 업데이트되는 경우 이 제약 조건에서 발생하는 작업을 가져오거나 설정합니다. |
메서드
| Name | Description |
|---|---|
| CheckStateForProperty() |
이 제약 조건이 DataSet 속한 값을 가져옵니다. (다음에서 상속됨 Constraint) |
| Equals(Object) |
현재 ForeignKeyConstraint 가 지정된 개체와 동일한지 여부를 나타내는 값을 가져옵니다. |
| GetHashCode() |
개체의 이 인스턴스 ForeignKeyConstraint 에 대한 해시 코드를 가져옵니다. |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| SetDataSet(DataSet) |
제약 조건의 DataSet. (다음에서 상속됨 Constraint) |
| ToString() |
문자열로 ConstraintName있는 경우 ,를 가져옵니다. (다음에서 상속됨 Constraint) |
적용 대상
스레드 보안
이 형식은 다중 스레드 읽기 작업에 안전합니다. 모든 쓰기 작업을 동기화해야 합니다.