Skip to main content
Next section

Aliases

Specifies additional names for this property for use via object access.

Usage

To specify additional names for the property, use the following syntax:

Property name As classname [ Aliases=othernames ]; 
Copy code to clipboard

Where othernames is a comma-separated list of valid property names, enclosed in curly braces.

Details

If you specify the Aliases keyword, the compiler creates the given alias or aliases, which point to the same underlying data that the original property points to. For example, suppose we redefine the Name property of Sample.Person as follows:

Property Name As %String(POPSPEC = "Name()") [ Aliases = {Alternate}, Required ];
Copy code to clipboard

Then your code can then work with either the Name property or the equivalent Alternate property, as shown in the following Terminal session:

SAMPLES>set p=##class(Sample.Person).%OpenId(1)
 
SAMPLES>w p.Name
Fripp,Charles Z.
SAMPLES>w p.Alternate
Fripp,Charles Z.
SAMPLES>set p.Alternate="Anderson,Neville J."
 
SAMPLES>w p.Name
Anderson,Neville J.
Copy code to clipboard

Any property methods associated with the original property are also defined for each alias property, so in this example AlternateIsValid() is callable and returns the same result as NameIsValid() method does. Also if you override a property method (for example, writing a custom NameGet() method), then that override automatically applies to the alias property or properties.

Note:

This keyword has no effect on the SQL projection of the property.

Default

By default, this keyword is null and a property has no aliases.

Example

Property PropA As %String [ Aliases={OtherName,OtherName2} ]; 
Copy code to clipboard

See Also