当前位置:网站首页>属性关键字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 是下列之一:
onemanyparentchildren
详解
此关键字指定关系属性cardinality。
关系属性需要cardinality关键字。它被非关系属性忽略。
默认
没有默认值。定义关系时,必须指定Cardinality关键字。
示例
Relationship Chapters As Chapter [ Cardinality = many; inverse = Book ];第九十六章 属性关键字 - ClientName
指定此属性的客户端投影使用的别名。
用法
若要在将类投影到客户端语言时重写此属性的默认名称,请使用以下语法:
Property name As classname [ ClientName = clientname ];其中clientname是在客户端语言中使用的名称。
详解
当属性被投影到客户端语言时,此关键字允许定义属性的替代名称。如果属性名包含客户端语言中不允许的字符,这尤其有用。
默认
如果省略此关键字,属性名称将用作客户端名称。
边栏推荐
- 我那“不好惹”的00后下属:不差钱,怼领导,抵制加班
- 实现IP地址归属地显示功能、号码归属地查询
- 【堡垒机】云堡垒机和普通堡垒机的区别是什么?
- JS function returns multiple values
- Redis can only cache? Too out!
- Excerpt from "misogyny: female disgust in Japan"
- Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
- How far can it go to adopt a cow by selling the concept to the market?
- 2022-7-7 Leetcode 844.比较含退格的字符串
- 【日常训练】648. 单词替换
猜你喜欢

Cmake learning and use notes (1)

Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)
![[fortress machine] what is the difference between cloud fortress machine and ordinary fortress machine?](/img/fb/17e029b1d955965d7e2e0f58701d91.png)
[fortress machine] what is the difference between cloud fortress machine and ordinary fortress machine?

Cinnamon taskbar speed

Error lnk2019: unresolved external symbol

Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou

My "troublesome" subordinates after 00: not bad for money, against leaders, and resist overtime

Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)

Ogre introduction

交付效率提升52倍,运营效率提升10倍,看《金融云原生技术实践案例汇编》(附下载)
随机推荐
高等数学---第八章多元函数微分学1
Final review notes of single chip microcomputer principle
如何让join跑得更快?
2022-7-6 Leetcode 977. Square of ordered array
一文读懂数仓中的pg_stat
Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
Introduction to database system - Chapter 1 introduction [conceptual model, hierarchical model and three-level mode (external mode, mode, internal mode)]
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
单片机学习笔记之点亮led 灯
Simple and easy-to-use code specification
2022-7-7 Leetcode 844.比较含退格的字符串
Shell batch file name (excluding extension) lowercase to uppercase
118. 杨辉三角
Mongodb replication (replica set) summary
【等保】云计算安全扩展要求关注的安全目标和实现方式区分原则有哪些?
记一次 .NET 某新能源系统 线程疯涨 分析
Talk about pseudo sharing
Mongodb command summary
Mongodb meets spark (for integration)
Leetcode simple question sharing (20)