A list of settings and the properties about an object’s related Child objects are displayed under the Children node for each Object in the schema.
The screen shot below displays settings and properties for the Student object's Child Enrollment. The Enrollment table object is considered a Child of Student because there is a foreign key column in the Enrollment table – FKStudentId – which references the Student table.
If you were instead viewing the Enrollment object, Student is listed under the Parent node of Enrollment as shown below. Schedule is also considered a Parent of the Enrollment object as well.
The settings a Root object can apply on its Child objects are explained below:
Child Object Name: Default: Mapped Table Name
This setting controls how the Parent object will reference the Child object within the generated data layer object model. Changing a Child object’s name will not change the object name but rather how the Parent will reference the Child object.
Add/Delete/New Scope: Default: public virtual
There are four possible settings which determine how or if the Child object can be modified by the Parent.
public virtual |
(default) Will define that object method is accessible from an object instance, or any subclass. This setting also indicates that the property method can be overridden by a descended class if desired. |
protected virtual |
This method signature will only allow descendant classes from viewing or setting the property values. |
internal |
Will define a method that is publicly accessible by all objects in an assembly (but not from outside the assembly). |
None |
The method signature for the property will be set to public virtual. However, the internal get and/or set methods will not be generated for the Property. If both Get Accessor Scope and Set Mutator Scope are set to None no method is generated for the Property at all. Setting Set Mutator Scope to None will create a Property signature which is read-only |
Get Accessor Scope: Default: public virtual
There are four possible settings which determine the visibility of the Child object within the Parent.
public virtual |
(default) Will define that object method is accessible from an object instance, or any subclass. This setting also indicates that the property method can be overridden by a descended class if desired. |
protected virtual |
This method signature will only allow descendant classes from viewing or setting the property values. |
internal |
Will define a method that is publicly accessible by all objects in an assembly (but not from outside the assembly). |
None |
The method signature for the property will be set to public virtual. However, the internal get and/or set methods will not be generated for the Property. If both Get Accessor Scope and Set Mutator Scope are set to None NO method is generated for the Property at all. Setting Set Mutator Scope to None will create a Property signature which is read-only |
Collection(1:N)
Single Object(1:1) Default: Collection(1:N)
This radio box determines whether the Parent object should return a collection of related objects or a single object to the calling Root object. Relationally Parent/Child relationships can be defined as either one-to-many or one-to-one. If you know that a relationship between two tables will be one-to-one - only one Enrollment record will map to one Student record - you can set this radio box to be Single Object(1:1). When a Student object(s) is returned with related Enrollment information only a single object (row of data) will be returned instead of a collection of objects (rows of data). In most cases you can leave the default setting to return a collection of related child records. However, there are cases where it is more convenient to work with a single object than with a Collection object.
The information you can view about a Child object relationship include:
Foreign Key: The mapped foreign key column name
Displays the foreign key column name within the Child table that references the Parent table and binds the relationship between the two objects as Parent/Child. In this example FKStudentID is a foreign key in the Enrollment table.
Cascade Deletes/Updates
One area to be aware of is how deleting a Parent record will affect the related Child records. ORM.NET will generate the underlying SQL statements based on how the relationship constraints are defined within the SQL schema. You can view how these settings have been applied within the ORM.NET object browser under Children Node property page. The example above shows that the relationship defined for the Enrollment object – Child of Student - is set so that SQL will “Enforce relationship for INSERTS and UPDATEs” but will not “Cascade Delete Related Records” or "Cascade Update Related fields".
Please refer to the SQL Server Books Online for more information on about Cascade Deletes and Updates Transact SQL.
NOTE: Relationship and constraint properties are retrieved from the database schema definition and are read-only. In order to change these constraints you will need to make them within SQL Enterprise manager and then click the Refresh Model button in order for the ORM.NET Object Browser to correctly display the latest database changes.