System.Data Namespace
Represents a collection of constraints for a DataTable.
The ConstraintCollection represents the set of constraints defined for a given DataTable. This collection is accessed via the DataTable.Constraints property.
The ConstraintCollection can contain both UniqueConstraint and ForeignKeyConstraint objects for the table. A UniqueConstraint ensures that data in a given column is always unique to preserve the data integrity. A ForeignKeyConstraint determines what will happen in related tables when data in the DataTable is either updated or deleted.
A UniqueConstraint is created when a DataColumn with its Unique property set to true is added to a DataTable object' s DataColumnCollection. A ForeignKeyConstraint is created when a DataRelation is added to a DataSet object's DataRelationCollection.
NOTE: When a DataRelation is added to to a DataSet, both types of constraint are created automatically. The UniqueConstraint is applied to the primary key column in the parent DataTable, and the constraint is added to that table' s ConstraintCollection. The ForeignKeyConstraint is applied to the primary key column and the foreign key column, and the constraint is added to the child table' s ConstraintCollection.
Like most data collections in ADO.NET, the ConstraintCollection uses standard collection methods such as Add, Clear, and Remove. In addition, the Contains method can be used to check for the existence of a particular constraint in the collection.
ForeignKeyConstraint UniqueConstraint DataRelation