当前位置:网站首页>属性关键字Aliases,Calculated,Cardinality,ClientName
属性关键字Aliases,Calculated,Cardinality,ClientName
2022-07-07 11:47:00 【用户7741497】
第九十三章 属性关键字 - Aliases
指定此属性的其他名称,以便通过对象访问使用。
用法
要为属性指定其他名称,请使用以下语法:
Property name As classname [ Aliases=othernames ];
其中othernames
是用逗号分隔的有效属性名列表,用大括号括起来。
详解
如果指定别名关键字,编译器会创建一个或多个给定的别名,这些别名指向原始属性所指向的同一基础数据。例如,重新定义Sample.Person
的Name
属性,如下所示:
Property Name As %String(POPSPEC = "Name()") [ Aliases = {Alternate}, Required ];
然后,代码可以使用Name
属性或等效的Alternate
属性,如以下终端会话所示:
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.
还为每个别名属性定义了与原始属性关联的任何属性方法,因此在本例中,AlternateIsValid()
是可调用的,并返回与NameIsValid()
方法相同的结果。此外,如果覆盖属性方法(例如,编写自定义NameGet()
方法),则该覆盖将自动应用于一个或多个别名属性。
注意:此关键字对属性的SQL投影没有影响。
默认
默认情况下,此关键字为NULL,并且属性没有别名。
示例
Property PropA As %String [ Aliases={OtherName,OtherName2} ];
第九十四章 属性关键字 - Calculated
指定在实例化包含此属性的对象时,没有为其分配内存中存储。
用法
若要指定没有为该属性分配内存中存储,请使用以下语法:
Property name As classname [ Calculated ];
否则,请省略此关键字或将该词放在该关键字之前。
详解
此关键字指定在实例化包含该属性的对象时,没有为该属性分配内存中存储。
在定义不需要任何内存存储的属性时,请使用此关键字。有两种方法可以指定此属性的值:
- 定义属性的
get
(可能还有set
)方法。例如,对于Age
属性,可以提供AgeGet
方法,该方法根据当前时间和DateOfBirth
属性的值确定一个人的当前年龄。 - 将此属性定义为计算属性;它使用
SqlComputed
关键字和相关关键字。
子类继承计算的关键字,不能重写它。
默认
Calculated
关键字的默认值为False
。
Property Age as %Integer [ Calculated ];
第九十五章 属性关键字 - Cardinality
指定此关系属性的基数cardinality
。关系属性Required
。不用于其他属性。
用法
要指定关系属性的基数,请使用以下语法:
Relationship relname As classname [ Cardinality = cardinality; inverse = inverse ];
其中cardinality
是下列之一:
one
many
parent
children
详解
此关键字指定关系属性cardinality
。
关系属性需要cardinality
关键字。它被非关系属性忽略。
默认
没有默认值。定义关系时,必须指定Cardinality
关键字。
示例
Relationship Chapters As Chapter [ Cardinality = many; inverse = Book ];
第九十六章 属性关键字 - ClientName
指定此属性的客户端投影使用的别名。
用法
若要在将类投影到客户端语言时重写此属性的默认名称,请使用以下语法:
Property name As classname [ ClientName = clientname ];
其中clientname
是在客户端语言中使用的名称。
详解
当属性被投影到客户端语言时,此关键字允许定义属性的替代名称。如果属性名包含客户端语言中不允许的字符,这尤其有用。
默认
如果省略此关键字,属性名称将用作客户端名称。
边栏推荐
- Esp32 ① compilation environment
- Distributed transaction solution
- Leetcode simple question sharing (20)
- [etc.] what are the security objectives and implementation methods that cloud computing security expansion requires to focus on?
- mysql 局域网内访问不到的问题
- Some principles of mongodb optimization
- What are the principles for distinguishing the security objectives and implementation methods that cloud computing security expansion requires to focus on?
- Leecode3. Longest substring without repeated characters
- JS slow motion animation principle teaching (super detail)
- ROS机器人更换新雷达需要重新配置哪些参数
猜你喜欢
Write it down once Net a new energy system thread surge analysis
高等数学---第八章多元函数微分学1
2022-7-6 Leetcode 977. Square of ordered array
Centso7 OpenSSL error Verify return code: 20 (unable to get local issuer certificate)
566. 重塑矩阵
2022-7-6 Leetcode 977.有序数组的平方
Excerpt from "misogyny: female disgust in Japan"
室內ROS機器人導航調試記錄(膨脹半徑的選取經驗)
LIS longest ascending subsequence problem (dynamic programming, greed + dichotomy)
. Net core about redis pipeline and transactions
随机推荐
QQ的药,腾讯的票
Read PG in data warehouse in one article_ stat
Data refresh of recyclerview
2022-7-6 使用SIGURG来接受外带数据,不知道为什么打印不出来
Storage principle inside mongodb
Introduction to database system - Chapter 1 introduction [conceptual model, hierarchical model and three-level mode (external mode, mode, internal mode)]
mysql 局域网内访问不到的问题
《厌女:日本的女性嫌恶》摘录
LeetCode简单题分享(20)
实现IP地址归属地显示功能、号码归属地查询
[QNX Hypervisor 2.2用户手册]6.3.4 虚拟寄存器(guest_shm.h)
flask session伪造之hctf admin
Getting started with cinnamon applet
MySQL error 28 and solution
"New red flag Cup" desktop application creativity competition 2022
. Net core about redis pipeline and transactions
数据库系统概论-第一章绪论【概念模型、层次模型和三级模式(外模式、模式、内模式)】
Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou
How did Guotai Junan Securities open an account? Is it safe to open an account?
Help tenants