Aliases
Usage
To specify additional names for the property, use the following syntax:
Property name As classname [ Aliases=othernames ];
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.PersonOpens in a new tab as follows:
Property Name As %String(POPSPEC = "Name()") [ Aliases = {Alternate}, Required ];
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.
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.
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} ];
See Also
-
“Property Definitions” in this book
-
“Defining and Using Literal Properties” in Using Caché Objects
-
“Working with Collections” in Using Caché Objects
-
“Working with Streams” in Using Caché Objects
-
“Defining and Using Object-Valued Properties” in Using Caché Objects
-
“Defining and Using Relationships” in Using Caché Objects
-
“Introduction to Compiler Keywords” in Using Caché Objects