Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
inverse
Programmer's Guide > OpenAccess ORM Classic (Old API) > Programming With OpenAccess > Metadata Extension Reference > inverse

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.

Sets the name of the field used to complete a collection implemented using an inverse reference or collection field in the element class (one-to-many or many-to-many relationship).

one-to-many inverse

If the inverse field is a reference then a one-to-many relationship is created. No link table will be created between the classes; as the field itself can be used to find all the elements in the collection. The field must reference the class with the collection. If the managed extension is set to true, then the inverse field is automatically set or cleared when objects are added or removed from the collection. The collection should never be replaced with a new instance (See One-to-many Mapping).

Copy Code
<field name="lines">
    <collection element-type="OrderLine">
      <extension key="inverse" value="order" />
      <extension key="managed" value="true" />
    </collection>
</field>

An index containing the foreign key columns will be added to the referenced table (see Controlling index generation for a one-to-many collection).

many-to-many inverse

If the inverse field is a collection then a many-to-many relationship is created. The link table used by the other side of the relationship is used to complete the collection. If the managed extension is set to true, then anything done to the collection on one side is automatically applied to the other side. The collection should never be replaced with a new instance (See Many-to-many Mapping).

Copy Code
<class name="User">
    <field name="groups">
        <collection element-type="Groups" />
    </field>
</class>

<class name="Groups">
    <field name="users">
        <collection element-type="User">
           <extension key="inverse" value="groups" />
            <extension key="managed" value="true" />
        </collection>
    </field>
</class>

An index containing the foreign key columns will be added to the referenced table (see Controlling index generation for an one-to-many collection