mormot118ORM

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;

 

posted @ 2023-01-09 15:15  delphi中间件  阅读(86)  评论(0编辑  收藏  举报