CreateMDSDerivedProperty
Purpose
The CMetaClassDesc class CreateMDSDerivedProperty function creates a derived property description and associates it with the specified derived class.
Description
A derived property creates a join between the base class specified for the derived class and a property in a related class. A read of a derived class object will return all properties (base and derived) and searches can be performed on all of the properties of the derived class.
In the above metamodel, a derived class can be created with the base class of Book. The derived class (AuthBook) will have all properties of Book (name, description, title). Because the Author class is an origin class related to the Book class with the AuthorHasBooks relationship, derived properties can be created for each of the properties of the Author class (name, description, author). If we create one derived property with the property author in the Author class, the derived class will have the following properties:
There are no actual objects in a derived class. A derived class joins together properties in the base class and the properties in related classes.
Derived properties can be created from relationships from 1 to 6 levels. In the first level relationship, the destination class of the relationship must be the base class of the derived property. In the next level relationship, the destination class must be the origin class of the previous level relationship. This continues until the last relationship. Note in the following figure, the classes and relationships of the database model.
This is a valid hierarchy for derived properties. If a derived class was created with the base class Column, derived properties could be created from properties in the Table, Database, and DBSystem classes.
A derived class can contain derived properties from multiple related classes.
In the above metamodel, a derived class (ExBook) is created with the base class of Book. It has a derived property (author) using the author property of the Author class and a derived property (PublisherName) using the name property of the Publisher class.
Note that the name of the derived property can be the name of the base property if the name is a unique name for the properties in the base class and the derived class. In ExBook, the derived property, author, is the same name as the property in its class. However, the derived property, PublisherName, could not be given the name of the base property (name) as the base class already has a name property.
If multiple derived properties are defined for a derived class, their relationships must all be on the same hierarchical path. For example:
a derived class with a base class of Column could contain derived properties from the DBSystem, Database, and Table classes. An example, which is not permitted, is:
a derived class with a base class of Column CANNOT contain derived properties from both the View and Table classes.
Property names and RelativePropID must be unique in the derived class and the base class of the derived class.
The default OwnerID is the logged in user.
Syntax
HRESULT CreateMDSDerivedProperty(
CMetaPropertyDesc *&pPropertyDescObj,
LPCTSTR strPropertyName,
LPCTSTR strPropertyDesc,
LPCTSTR BasePropertyName,
MetaObjectIDVector &RelationshipsToProperty,
const long lRelativePropID,
const GUID& PropGUID = NULLGUID,
const OBJECTID_t lOwnerID = NULLLOID,
const OBJECTID_t SecurityProfileID = NULLLOID);
Argument |
In/Out |
Description |
PropertyDescObj |
Out |
If PropertyDescObj is a pointer to NULL, the object will be created by the API. The calling application is responsible for freeing the object. |
Name |
In |
The name of the derived property to create. The name must be unique to all properties in the derived class and to the base class. The name cannot be one of the reserved property names, which are: |
Desc |
In |
Property description |
BasePropertyName |
In |
The name of the property in the related class. |
RelationshipsToProperty |
In |
The list of relationships to follow to get to the related class. |
RelativePropID |
In |
The Relative Property ID is a user-defined id number for this property. The ID number must be unique for each property in a class and must be a positive number 501 or larger. Property values from 1 to 500 are reserved for MDS-defined property values. The Relative Property ID is used to identify the property in get and set functions. |
GID |
In |
GUID of this Property Description. |
OwnerID |
In |
OwnerID of this object. |
SecurityProfileID |
In |
Security profile assigned to the object. |