LinqConnect allows you to set the following parameters for mapped association:
Property | Type | Description |
---|---|---|
Name | String | The name of the association. This is often the same as the database's foreign-key constraint name. It is used to help to distinguish between multiple relationships in a single entity class referring to the same target entity class. Relationship properties on both sides of the relationship (if both are defined) must have the same name. |
Storage | String | The name of the underlying storage member. If specified, it tells LinqConnect how to bypass the public property accessor for the data member and interact with the raw value itself. If not specified LinqConnect gets and sets the value using the public accessor. It is recommended that all association members be properties with separate storage members identified. |
ThisKey | String | A comma-separated list of names of one or more members of this entity class that represent the key values on this side of the association. If not specified, the members are assumed to be the members that make up the primary key. |
OtherKey | String | A comma-separated list of names of one or more members of the target entity class that represent the key values on the other side of the association. If not specified, the members are assumed to be the members that make up the other entity class's primary key. |
IsUnique | Boolean | True if there a uniqueness constraint on the foreign key, indicating a true 1:1 relationship. This property is seldom used as 1:1 relationships are nearly impossible to manage within the database. Mostly entity models are defined using 1:n relationships even when they are treated as 1:1 by application developers. |
IsForeignKey | Boolean | True if the target "other" type of the association is the parent of the source type. With foreign-key to primary-key relationships, the side holding the foreign-key is the child and the side holding the primary key is the parent. |
DeleteRule | String | Used to add delete behavior to this association. For example, "CASCADE" would add "ON DELETE CASCADE" to the FK relationship. If set to null, no delete behavior is added. |
LinkTableName | String | Used for many-to-many associations. Defines the name of the many-to-many association table. |
LinkThisKey | String | Used for many-to-many associations. A comma-separated list of names of one or more columns of the intermediate many-to-many association table, corresponding to ThisKey members of this entity class. |
LinkOtherKey | String | Used for many-to-many associations. A comma-separated list of names of one or more columns of the intermediate many-to-many association table, corresponding to OtherKey members of the target entity class. |
Association attribute is used for defining an association.
Association tag is used for association mapping.
<Table> <Type Name="Company"> <Column Member="CompanyID" IsPrimaryKey="true" /> <Association Name="Company_Order" Member="Orders" Storage="_Orders" ThisKey="CompanyID" OtherKey="CompanyID" /> </Type> </Table> <Table> <Type Name="Order"> <Column Member="OrderID" IsPrimaryKey="true" /> <Column Member="CompanyID" CanBeNull="false" /> <Association Name="Company_Order" Member="Company" Storage="_Company" ThisKey="CompanyID" OtherKey="CompanyID" IsForeignKey="true" /> </Type> </Table>
FluentMappingBuilder class methods are used for mapping associations. See the Association Configuration Classes topic for more details.