当前位置:网站首页>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 .
边栏推荐
猜你喜欢
Distributed transaction solution
Write it down once Net a new energy system thread surge analysis
[dark horse morning post] Huawei refutes rumors about "military master" Chen Chunhua; Hengchi 5 has a pre-sale price of 179000 yuan; Jay Chou's new album MV has played more than 100 million in 3 hours
Help tenants
DID登陆-MetaMask
LED light of single chip microcomputer learning notes
LIS longest ascending subsequence problem (dynamic programming, greed + dichotomy)
社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生
. Net core about redis pipeline and transactions
带你掌握三层架构(建议收藏)
随机推荐
Detr introduction
Digital IC Design SPI
Lavarel之环境配置 .env
Cinnamon taskbar speed
1、深拷贝 2、call apply bind 3、for of for in 区别
Learning breakout 2 - about effective learning methods
高等数学---第八章多元函数微分学1
LeetCode简单题分享(20)
ES日志报错赏析-Limit of total fields
供应链供需预估-[时间序列]
室内ROS机器人导航调试记录(膨胀半径的选取经验)
3D Detection: 3D Box和点云 快速可视化
"New red flag Cup" desktop application creativity competition 2022
How to make join run faster?
Use of polarscatter function in MATLAB
648. Word replacement: the classic application of dictionary tree
使用day.js让时间 (显示为几分钟前 几小时前 几天前 几个月前 )
最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
648. 单词替换 : 字典树的经典运用
记一次 .NET 某新能源系统 线程疯涨 分析