2

这是从该项目中提取的代码(注意:为清晰起见重新格式化):

Class Util.Data.EmojiType Extends %Persistent
{

Property CodePoint As %Integer;

Property UnicodeChar As %String [ 
    Calculated, 
    ReadOnly, 
    SqlComputeCode = { set {*} = $wchar({CodePoint})}, 
    SqlComputed, 
    Transient 
];

// snip

Method UnicodeCharGet() As %String
{
     quit $wchar(..CodePoint)
}

现在,我真的不明白。为什么它既UnicodeChar是计算的具有自定义的 getter(哎呀),加上自定义的 getter 与SqlComputeCode?

如果我尝试得到这个属性,这一切的哪一部分会被触发?

4

1 回答 1

4

即使属性未计算,也可以调用自定义 getter。但仅适用于对象访问模式。并且要通过 SQL 查询获得计算值,属性应该已经定义了所有属性:Calculated、SqlComputed 和 SqlComputeCode。如果定义了 SqlComputeCode,则此代码仅用于 SQL 查询。当属性有计算属性,但没有 SqlComputed 时,它不会出现在 SQL 结果中。

SqlComputed ,计算

于 2016-02-29T10:08:57.213 回答