Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
Mapping a Reference Field
Programmer's Guide > OpenAccess ORM Classic (Old API) > Programming With OpenAccess > Mapping > Simple and Reference Fields > Mapping a Reference Field

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

A reference field is implemented by adding a column that refers to the primary key of the referenced class. The default mapping (column properties) for a reference field are taken from the primary key column(s) of the referenced class. You should be careful if you change anything other than the name of the column as it must be comparable with the referenced primary key in SQL statements.

Reference to Single Column Primary Key

If the primary key of the referenced class consists of a single column then column properties are set using db-column extensions in the same was as done for a simple field:

Copy Code
<field name="customer">
 
<extension key="db-column">
   
<extension key="db-column-name" value="custid" />
 
</extension>
</
field>

Reference to Composite Primary Key

If the referenced class has a composite primary key (more than one column — i.e., multiple field identity with has more than one primary key field) then you must use a db-ref extension for each field in the primary key (see db-ref). Using composite primary keys is not recommended—but is often required—to map to legacy database schemas:

Copy Code
<field name="refa">
 
<extension key="db-ref" value="partA">
   
<extension key="db-column">
     
<extension key="db-column-name" value="foo" />
   
</extension>
 
</extension>
 
<extension key="db-ref" value="partB">
   
<extension key="db-column">
     
<extension key="db-column-name" value="bar" />
   
</extension>
 
</extension>
</
field>