查看: 62|回复: 0

mormot118ORM

[复制链接]

2

主题

0

回帖

0

积分

热心网友

金币
0
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2010-7-8
发表于 2023-1-9 15:15:00 | 显示全部楼层 |阅读模式

mormot118ORM

unit mORMot;

  /// root class for defining and mapping database records
  // - inherits a class from TSQLRecord, and add published properties to describe
  // the table columns (see TPropInfo for SQL and Delphi type mapping/conversion)
  // - this published properties can be auto-filled from TSQLTable answer with
  // FillPrepare() and FillRow(), or FillFrom() with TSQLTable or JSON data
  // - these published properties can be converted back into UTF-8 encoded SQL
  // source with GetSQLValues or GetSQLSet or into JSON format with GetJSONValues
  // - BLOB fields are decoded to auto-freeing TSQLRawBlob properties
  // - any published property defined as a T*ObjArray dynamic array storage
  // of persistents (via TJSONSerializer.RegisterObjArrayForJSON) will be freed
  // - consider inherit from TSQLRecordNoCase and TSQLRecordNoCaseExtended if
  // you expect regular NOCASE collation and smaller (but not standard JSON)
  // variant fields persistence
  // - is called TOrm in mORMot 2
  TSQLRecord = class(TObject)

///用于定义和映射数据库记录的根类

//-从TSQLRecord继承一个类,并添加已发布的属性来描述

//表列(请参阅TPropInfo for SQL和Delphi类型映射/转换)

//-可以使用

//FillPrepare()和FillRow(),或具有TSQLTable或JSON数据的FillFrom()

//-这些已发布的属性可以转换回UTF-8编码的SQL

//具有GetSQLValues或GetSQLSet的源代码,或具有GetJSONValues的JSON格式

//-BLOB字段被解码以自动释放TSQLRawBlob属性

//-定义为T*ObjArray动态数组存储的任何已发布属性

//的持久性(通过TJSONSerializer.RegisterObjArrayForJSON)将被释放

//-如果出现以下情况,请考虑从TSQLRecordNoCase和TSQLRecordNoCaseExtended继承

//您需要常规NOCASE排序规则和更小的排序规则(但不是标准JSON)

//变量字段持久性

//-在mORMot 2中称为TOrm

  TSQLRecordPeople = class(TSQLRecord)
  protected
    fData: TSQLRawBlob;
    fFirstName: RawUTF8;
    fLastName: RawUTF8;
    fYearOfBirth: integer;
    fYearOfDeath: word;
    fAnother: TSQLRecordPeople;
    {$ifdef TESTRECORD}
    fSexe: TPeopleSexe;
    fSimple: TTestCustomJSONArraySimpleArray;
  public
    class procedure InternalRegisterCustomProperties(Props: TSQLRecordProperties); override;
    {$endif}
  published
    property FirstName: RawUTF8 read fFirstName write fFirstName;
    property LastName: RawUTF8 read fLastName write fLastName;
    property Data: TSQLRawBlob read fData write fData;
    property YearOfBirth: integer read fYearOfBirth write fYearOfBirth;
    property YearOfDeath: word read fYearOfDeath write fYearOfDeath;
    property Another: TSQLRecordPeople read fAnother write fAnother;
  {$ifdef TESTRECORD}
    property Sexe: TPeopleSexe read fSexe write fSexe;
  public
    property Simple: TTestCustomJSONArraySimpleArray read fSimple;
  {$endif}
  end;

 

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部