I was studying DataRelations
in Ado.Net and came across this constructor
public DataRelation(
string relationName,
DataColumn parentColumn,
DataColumn childColumn,
bool createConstraints
)
Here, the last parameter is createConstraints
, which is explained by MSDN as
createConstraints
Type: System.Boolean
A value that indicates whether constraints are created. true, if constraints are created. Otherwise, false.
If I set it to false
then what happens? How does it create a foreign key without constraints?
Yes, the relationship will be created without a constraint being added to ConstraintCollection
More on constraints:
Relationships can also cascade various changes from the parent DataRow to its child rows. To control how values are changed in child rows, add a ForeignKeyConstraint to the ConstraintCollection of the DataTable object. The ConstraintCollection determines what action to take when a value in a parent table is deleted or updated.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.