Relationships in relational databases are typically represented as foreign key values referring to primary keys in other tables. To navigate between them, you must use a relational join operation. Objects, on the other hand, refer to each other using property references or collections of references navigated using "dot" notation. LinqConnect defines an Association attribute you can apply to a member used to represent a relationship. An association relationship is one like a foreign-key to primary-key relationship that is made by matching column values between tables.
To define a relationship use the EntitySet container in the parent entity.
The Company class now has a property that declares the relationship between companies and their orders. The Orders property is of type EntitySet because the relationship is one-to-many. We use the OtherKey property of the Association attribute to describe how this association is done. It specifies the names of the properties in the related class to be compared with this one. There was also a ThisKey property we did not specify. Normally, we would use it to list the members on this side of the relationship. However, by omitting it we allow LinqConnect to infer them from the members that make up the primary key.
Now take a look at the relationship declaration at the Order class side.
The Order class uses the EntityRef type to describe the relationship back to the company. EntityRef class should be used to support deferred loading. The Association attribute specifies the ThisKey property for the Company property since the non-inferable members are now on this side of the relationship.
Also pay attention to the Storage property. It tells LinqConnect which private member is used to hold the value of the property. This allows LinqConnect to bypass your public property accessors when it stores and retrieves their value to avoid any custom business logic. If the storage property is not specified, the public accessors will be used instead. You may use the Storage property with Column attributes as well.