asp.net.ph

ConstraintCollection Class

System.Data Namespace


Represents a collection of constraints for a DataTable.

ConstraintCollection Class Members

Collapse   Properties

Visibility Name Value Type Accessibility
public Item ( String name ) Constraint [ Get ]
public Item ( Int32 index ) Constraint [ Get ]

Collapse   Methods

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

Collapse   Events

Multicast Name Type
multicast CollectionChanged CollectionChangeEventHandler

Remarks

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.


See Also

ForeignKeyConstraint   UniqueConstraint   DataRelation Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 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 asp.net.ph