DataLink Object

The DataLink object represents a descriptor of link between a feature type and a table of GDB/external database or between a feature type and a cataloged query of external database. To set a link, it is necessary to create an object DataLink by the method FeatureType::CreateDataLinkForTable or FeatureType::CreateDataLinkForQuery, to set up it and add to the FeatureType::DataLinks collection. To destroy a link, the link descriptor must be removed from the FeatureType::DataLinks collection.

To set a link between a feature type and a table of GDB/external database, use the FeatureType::CreateDataLinkForTable method. The argument of this method is a table being linked (object Table). A temporary GDB table cannot be used as the linked table. To set the link between a feature type and a cataloged query of external database, use the FeatureType::CreateDataLinkForQuery method. The argument of this method is a query being linked (object Query). It is necessary to set up the link descriptor after its creation and before adding to the FeatureType::DataLinks collection:

To set a link mode by the DataLink::LinkCategory property. Description of link modes as well as restrictions on setting and changing them after adding DataLink objects to the FeatureType::DataLinks collection is given in the table "Link modes between feature type and table/query".

In case of direct link (the constant is gdbLinkDirect), it is necessary to set a field of direct link by the DataLink::DirectField property. This field must belong to an external database table or cataloged query upon which the descriptor of the link has been built. The field must be of type integer and have precision not less than 10 decimal digits (you can determine a field precision by the Field::Precision property). The field of direct link stores an internal number of a feature of specified type. The value of this field connects features with records of table or query.

In case of indirect link (the constant is gdbLinkIndirect), it is necessary to set a cross table by the DataLink::CrossTable property. This table must be a table of GDB (not a temporary one) and have the unique link mode (the constant is gdbLinkUniq) with a feature type, the owner of link descriptor. A temporary GDB table cannot be used as the cross table.

In case of indirect link (the constant is gdbLinkIndirect), it is necessary to establish correspondence between fields of linked table or query from external database and fields of cross table. You should create the IndirectFieldsPair object (a descriptor of correspondence between fields for indirect link) by the DataLink::CreateIndirectFieldsPair method for every pair of fields (a field of table or query and a field of cross table) and add it to the DataLink::IndirectFieldsPairs collection. To get a feature connected with a record from a table or query of external database, the record from the cross table is determined by values of fields of indirect link and then the feature connected with this record from the cross table. In backward direction, the record connected with the feature is determined in the cross table and then the record (records) from a table or query of external database is determined by values of fields of indirect link in the record of cross table.

The direct link between a table or query of external database and a feature type is more effective than the indirect link. However, you should understand that GDB reorganization with the mode of changing internal numbers (performed by the GDBEngine::CompactGDB method with mode == gdbCompactNoKeepISN) will destroy connections between records and features. Internal numbers may change when copying or moving features from one layer to another (to another map or GDB) what will destroy connections as well.

The indirect link between a table or query of external database and a feature type is less effective than the direct link. However, none of the modes of reorganization will destroy such a link.