UniqueConstraint クラス
定義
すべての値が一意である必要がある列のセットに対する制限を表します。Represents a restriction on a set of columns in which all values must be unique.
public ref class UniqueConstraint : System::Data::Constraint
public class UniqueConstraint : System.Data.Constraint
[System.Serializable]
public class UniqueConstraint : System.Data.Constraint
type UniqueConstraint = class
inherit Constraint
[<System.Serializable>]
type UniqueConstraint = class
inherit Constraint
Public Class UniqueConstraint
Inherits Constraint
- 継承
- 属性
例
をに追加し、 UniqueConstraint DataSet EnforceConstraints プロパティをに設定する例を次に示し true
ます。The following example adds a UniqueConstraint to a DataSet and sets the EnforceConstraints property to true
.
Public Sub CreateDataTable()
Dim dataTable As New DataTable()
dataTable.Columns.Add("CustomerID", Type.GetType("System.String"))
dataTable.Columns.Add("CompanyName", Type.GetType("System.String"))
Dim uniqueConstraint As UniqueConstraint = _
New UniqueConstraint("CustConstraint", _
New DataColumn() {dataTable.Columns("CustomerID"), _
dataTable.Columns("CompanyName")})
dataTable.Constraints.Add(uniqueConstraint)
End Sub
注釈
は、 UniqueConstraint 主キーの値が一意であることを確認するために、1つの列 (または列) に対して適用されます。The UniqueConstraint is enforced on a single column (or columns) to ensure that a primary key value is unique.
プロパティがに設定されていない限り、制約は適用されません EnforceConstraints true
。Constraints are not enforced unless the EnforceConstraints property is set to true
.
A DataSet が2番目のにマージされる場合 DataSet 、すべてのマージが完了するまで制約は適用されません。When the a DataSet is merged with a second DataSet, constraints are not enforced until all merges are completed.
コンストラクター
UniqueConstraint(DataColumn) |
UniqueConstraint を指定して、DataColumn クラスの新しいインスタンスを初期化します。Initializes a new instance of the UniqueConstraint class with the specified DataColumn. |
UniqueConstraint(DataColumn, Boolean) |
制約する UniqueConstraint と、その制約が主キーかどうかを示す値を指定して、DataColumn クラスの新しいインスタンスを初期化します。Initializes a new instance of the UniqueConstraint class with the DataColumn to constrain, and a value specifying whether the constraint is a primary key. |
UniqueConstraint(DataColumn[]) |
UniqueConstraint オブジェクトの配列を指定して、DataColumn クラスの新しいインスタンスを初期化します。Initializes a new instance of the UniqueConstraint class with the given array of DataColumn objects. |
UniqueConstraint(DataColumn[], Boolean) |
制約する UniqueConstraint オブジェクトの配列と、その制約が主キーかどうかを示す値を指定して、DataColumn クラスの新しいインスタンスを初期化します。Initializes a new instance of the UniqueConstraint class with an array of DataColumn objects to constrain, and a value specifying whether the constraint is a primary key. |
UniqueConstraint(String, DataColumn) |
名前と UniqueConstraint を指定して、DataColumn クラスの新しいインスタンスを初期化します。Initializes a new instance of the UniqueConstraint class with the specified name and DataColumn. |
UniqueConstraint(String, DataColumn, Boolean) |
名前、制約する UniqueConstraint、およびその制約が主キーかどうかを示す値を指定して、DataColumn クラスの新しいインスタンスを初期化します。Initializes a new instance of the UniqueConstraint class with the specified name, the DataColumn to constrain, and a value specifying whether the constraint is a primary key. |
UniqueConstraint(String, DataColumn[]) |
名前と UniqueConstraint オブジェクトの配列を指定して、DataColumn クラスの新しいインスタンスを初期化します。Initializes a new instance of the UniqueConstraint class with the specified name and array of DataColumn objects. |
UniqueConstraint(String, DataColumn[], Boolean) |
名前、制約する UniqueConstraint オブジェクトの配列、およびその制約が主キーかどうかを示す値を指定して、DataColumn クラスの新しいインスタンスを初期化します。Initializes a new instance of the UniqueConstraint class with the specified name, an array of DataColumn objects to constrain, and a value specifying whether the constraint is a primary key. |
UniqueConstraint(String, String[], Boolean) |
名前、制約する UniqueConstraint オブジェクトの配列、およびその制約が主キーかどうかを示す値を指定して、DataColumn クラスの新しいインスタンスを初期化します。Initializes a new instance of the UniqueConstraint class with the specified name, an array of DataColumn objects to constrain, and a value specifying whether the constraint is a primary key. |
プロパティ
_DataSet |
この制約が属する DataSet を取得します。Gets the DataSet to which this constraint belongs. (継承元 Constraint) |
Columns |
この制約が影響を与える列の配列を取得します。Gets the array of columns that this constraint affects. |
ConstraintName |
ConstraintCollection 内の制約の名前。The name of a constraint in the ConstraintCollection. (継承元 Constraint) |
ExtendedProperties |
ユーザー定義の制約のプロパティのコレクションを取得します。Gets the collection of user-defined constraint properties. (継承元 Constraint) |
IsPrimaryKey |
この制約が主キーに適用されるかどうかを示す値を取得します。Gets a value indicating whether or not the constraint is on a primary key. |
Table |
制約が属するテーブルを取得します。Gets the table to which this constraint belongs. |
メソッド
CheckStateForProperty() |
この制約が属する DataSet を取得します。Gets the DataSet to which this constraint belongs. (継承元 Constraint) |
Equals(Object) |
この制約と 2 つ目の制約を比較して、2 つの制約が等しいかどうかを判断します。Compares this constraint to a second to determine if both are identical. |
GetHashCode() |
UniqueConstraint オブジェクトのこのインスタンスのハッシュ コードを取得します。Gets the hash code of this instance of the UniqueConstraint object. |
GetType() |
現在のインスタンスの Type を取得します。Gets the Type of the current instance. (継承元 Object) |
MemberwiseClone() |
現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object. (継承元 Object) |
SetDataSet(DataSet) |
制約の DataSet を設定します。Sets the constraint's DataSet. (継承元 Constraint) |
ToString() |
ConstraintName がある場合は、この制約名を文字列として取得します。Gets the ConstraintName, if there is one, as a string. (継承元 Constraint) |
適用対象
スレッド セーフ
この型は、マルチスレッドの読み取り操作に適しています。This type is suitable for multithreaded read operations. 書き込み操作はすべて同期する必要があります。You must synchronize any write operations.