| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ConstraintCollection ClassRepresents a collection of constraints for a DataTable.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Visibility | Name | Parameters | Return Type |
|---|---|---|---|
| public | Add | ( String name , DataColumn primaryKeyColumn , DataColumn foreignKeyColumn ) | Constraint |
| public | Add | ( String name , DataColumn primaryKeyColumns , DataColumn foreignKeyColumns ) | Constraint |
| public | Add | ( String name , DataColumn column , Boolean primaryKey ) | Constraint |
| public | Add | ( Constraint constraint ) | Void |
| public | Add | ( String name , DataColumn columns , Boolean primaryKey ) | Constraint |
| public | AddRange | ( Constraint constraints ) | Void |
| public | CanRemove | ( Constraint constraint ) | Boolean |
| public | Clear | ( ) | Void |
| public | Contains | ( String name ) | Boolean |
| public | CopyTo | ( Constraint array , Int32 index ) | Void |
| public | IndexOf | ( String constraintName ) | Int32 |
| public | IndexOf | ( Constraint constraint ) | Int32 |
| public | Remove | ( String name ) | Void |
| public | Remove | ( Constraint constraint ) | Void |
| public | RemoveAt | ( Int32 index ) | Void |
| Multicast | Name | Type |
|---|---|---|
| multicast | CollectionChanged | CollectionChangeEventHandler |
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
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme