当前位置:网站首页>属性关键字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
是在客户端语言中使用的名称。
详解
当属性被投影到客户端语言时,此关键字允许定义属性的替代名称。如果属性名包含客户端语言中不允许的字符,这尤其有用。
默认
如果省略此关键字,属性名称将用作客户端名称。
边栏推荐
- Shell batch file name (excluding extension) lowercase to uppercase
- 118. 杨辉三角
- 分布式事务解决方案
- What parameters need to be reconfigured to replace the new radar of ROS robot
- Deep understanding of array related problems in C language
- 2022-7-6 使用SIGURG来接受外带数据,不知道为什么打印不出来
- How to make join run faster?
- LIS longest ascending subsequence problem (dynamic programming, greed + dichotomy)
- Show the mathematical formula in El table
- 2022-7-7 Leetcode 34. Find the first and last positions of elements in a sorted array
猜你喜欢
Navicat运行sql文件导入数据不全或导入失败
Redis can only cache? Too out!
Navicat run SQL file import data incomplete or import failed
Introduce six open source protocols in detail (instructions for programmers)
2022-7-7 Leetcode 34. Find the first and last positions of elements in a sorted array
2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
Build a secure and trusted computing platform based on Kunpeng's native security
Realize the IP address home display function and number home query
Thread pool reject policy best practices
单片机学习笔记之点亮led 灯
随机推荐
Introduction and basic use of stored procedures
MySQL error 28 and solution
高端了8年,雅迪如今怎么样?
Split screen bug notes
交付效率提升52倍,运营效率提升10倍,看《金融云原生技术实践案例汇编》(附下载)
Some principles of mongodb optimization
Scripy tutorial classic practice [New Concept English]
2022-7-6 Leetcode27. Remove the element - I haven't done the problem for a long time. It's such an embarrassing day for double pointers
xshell连接服务器把密钥登陆改为密码登陆
1、深拷贝 2、call apply bind 3、for of for in 区别
postgresql array类型,每一项拼接
2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
Detr introduction
. Net core about redis pipeline and transactions
Custom thread pool rejection policy
JS function returns multiple values
Digital IC Design SPI
【日常训练】648. 单词替换
Mongodb command summary
2022-7-7 Leetcode 844.比较含退格的字符串