![]() ![]() ![]() Note: Using this rule can result in invalid data in the child table. With this setting, child records can be left as "orphans"-that is, they have no relationship to parent records. The change (update or delete) made to the parent record is also made in related records in the child table.Ĭhild records are not deleted, but the foreign key in the child records is set to DBNull. The rules that you can make are specified in the Rule enumeration and are listed in the following table. Referential integrity rulesĪs part of the foreign-key constraint, you can specify referential integrity rules that are applied at three points: For information on suspending constraints in a dataset, see Turn off constraints while filling a dataset. If you create a foreign-key constraint by using the DataRelation object, instances of the ForeignKe圜onstraint class are added to the DataRelation object's ChildKe圜onstraint property.Ī unique constraint is implemented either by simply setting the Unique property of a data column to true or by adding an instance of the UniqueConstraint class to the DataRelation object's ParentKe圜onstraint property. DataRelation objects and constraintsĪ DataRelation object is also used to create and enforce the following constraints:Ī unique constraint, which guarantees that a column in the table contains no duplicates.Ī foreign-key constraint, which can be used to maintain referential integrity between a parent and child table in a dataset.Ĭonstraints that you specify in a DataRelation object are implemented by automatically creating appropriate objects or setting properties. Instead, the DataRelation tracks the relationship between tables and keeps parent and child records in sync. When you use a DataRelation object, no new recordset is created. In a true join, records are taken from parent and child tables and put into a single, flat recordset. It is important to understand the difference between a true join and the function of a DataRelation object. It can enforce constraints for referential integrity, such as deleting related child records when you delete a parent record. It provides child records if you are in a parent record ( GetChildRows) and a parent record if you are working with a child record ( GetParentRow). It can make available the records related to a record you are working with. The DataRelation object performs two functions: Adding related tables to datasets by using the Data Source Configuration Wizard, or the Dataset Designer, creates and configures the DataRelation object for you. Entity Framework provides a more natural way to work with tabular data as object models, and it has a simpler programming interface.ĭatasets that contain related data tables use DataRelation objects to represent a parent/child relationship between the tables and to return related records from one another. ![]() NET applications use Entity Framework Core. Although datasets have proven to be a very successful technology, we recommend that new. They are especially useful for applications that enable users to modify data and persist the changes back to the database. NET Framework technologies from the early 2000s that enable applications to work with data in memory while the applications are disconnected from the database.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |