当前位置:网站首页>Attribute keywords aliases, calculated, cardinality, ClientName
Attribute keywords aliases, calculated, cardinality, ClientName
2022-07-07 13:52:00 【User 7741497】
Chapter 93 Attribute keyword - Aliases
Specify a different name for this property , In order to use through object access .
usage
To specify a different name for the attribute , Please use the following syntax :
Property name As classname [ Aliases=othernames ];
among othernames
Is a comma separated list of valid attribute names , Enclosed in braces .
Detailed explanation
If you specify an alias keyword , The compiler will create one or more given aliases , These aliases point to the same basic data that the original attribute points to . for example , Redefinition Sample.Person
Of Name
attribute , As shown below :
Property Name As %String(POPSPEC = "Name()") [ Aliases = {Alternate}, Required ];
then , The code can be used Name
Attribute or equivalent Alternate
attribute , 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 attribute method associated with the original attribute is also defined for each alias attribute , So in this case ,AlternateIsValid()
It's callable , And back with NameIsValid()
The same result . Besides , If the attribute method is overridden ( for example , Write custom NameGet()
Method ), Then the override will be automatically applied to one or more alias properties .
Be careful : This keyword is for attribute SQL Projection has no effect .
Default
By default , This keyword is NULL, And the attribute has no alias .
Example
Property PropA As %String [ Aliases={OtherName,OtherName2} ];
Chapter 94 Attribute keyword - Calculated
Specifies that when instantiating an object containing this property , There is no memory allocated for it .
usage
To specify that no in memory storage is allocated for this attribute , Please use the following syntax :
Property name As classname [ Calculated ];
otherwise , Please omit the keyword or put the word before the keyword .
Detailed explanation
This keyword specifies that when instantiating an object containing this attribute , No memory storage is allocated for this attribute .
When defining attributes that do not require any memory storage , Please use this keyword . There are two ways to specify the value of this property :
- Defining properties
get
( There may beset
) Method . for example , aboutAge
attribute , Can provideAgeGet
Method , This method is based on the current time andDateOfBirth
The value of the attribute determines a person's current age . - Define this attribute as a calculation attribute ; It USES
SqlComputed
Keywords and related keywords .
Subclasses inherit calculated keywords , It cannot be rewritten .
Default
Calculated
The default value of the keyword is False
.
Property Age as %Integer [ Calculated ];
Chapter 95 Attribute keyword - Cardinality
Specify the cardinality of this relationship property cardinality
. Relationship properties Required
. Not used for other properties .
usage
To specify the cardinality of the Relationship Attribute , Please use the following syntax :
Relationship relname As classname [ Cardinality = cardinality; inverse = inverse ];
among cardinality
Is one of the following :
one
many
parent
children
Detailed explanation
This keyword specifies the Relationship Attribute cardinality
.
Relationship attributes need cardinality
keyword . It is ignored by non relational attributes .
Default
No default . When defining relationships , Must specify Cardinality
keyword .
Example
Relationship Chapters As Chapter [ Cardinality = many; inverse = Book ];
Chapter 96 Attribute keyword - ClientName
Specify the alias used by the client projection of this property .
usage
To override the default name of this property when projecting a class to the client language , Please use the following syntax :
Property name As classname [ ClientName = clientname ];
among clientname
Is the name used in the client language .
Detailed explanation
When attributes are projected to the client language , This keyword allows you to define alternative names for attributes . If the attribute name contains characters that are not allowed in the client language , This is especially useful .
Default
If you omit this keyword , The attribute name will be used as the client name .
边栏推荐
猜你喜欢
2022-7-6 Leetcode 977. Square of ordered array
Esp32 construction engineering add components
How to make join run faster?
2022-7-7 Leetcode 844. Compare strings with backspace
Redis can only cache? Too out!
单片机学习笔记之点亮led 灯
JS slow motion animation principle teaching (super detail)
社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生
Introduction and basic use of stored procedures
2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
随机推荐
Deep understanding of array related problems in C language
"Song of ice and fire" in the eleventh issue of "open source Roundtable" -- how to balance the natural contradiction between open source and security?
Battle Atlas: 12 scenarios detailing the requirements for container safety construction
MySQL error 28 and solution
Data refresh of recyclerview
Help tenants
社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生
内存溢出和内存泄漏的区别
JS slow motion animation principle teaching (super detail)
Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)
《厌女:日本的女性嫌恶》摘录
2022-7-6 Leetcode 977. Square of ordered array
[daily training -- Tencent select 50] 231 Power of 2
Drawerlayout suppress sideslip display
Excerpt from "misogyny: female disgust in Japan"
Help tenants
Ways to improve the performance of raspberry pie
室内ROS机器人导航调试记录(膨胀半径的选取经验)
单片机学习笔记之点亮led 灯
Introduction to database system - Chapter 1 introduction [conceptual model, hierarchical model and three-level mode (external mode, mode, internal mode)]