新版本的变更 / Delphi 2010

// *** before: ***
// extra facts about a class were kept beside the class: in a table, in a
// registration call, or in a naming convention nobody could check
type
  TPerson = class
  private
    FName: string;
  published
    property Name: string read FName write FName;
  end;

initialization
  //the mapping had to be written twice and kept in sync by hand
  Mapper.Register(TPerson, 'PEOPLE');
  Mapper.RegisterField(TPerson, 'FName''FULL_NAME');

// *** in version 2010: ***
type
  TableAttribute = class(TCustomAttribute)
  private
    FName: string;
  public
    constructor Create(const AName: string);
    property Name: string read FName;
  end;

  ColumnAttribute = class(TCustomAttribute)
  private
    FName: string;
  public
    constructor Create(const AName: string);
    property Name: string read FName;
  end;

  [Table('PEOPLE')]
  TPerson = class
  private
    [Column('FULL_NAME')]
    FName: string;
  end;

constructor TableAttribute.Create(const AName: string);
begin
  FName := AName;
end;

// the fact now travels with the declaration and is read back by RTTI
var
  A: TCustomAttribute;
begin
  for A in Ctx.GetType(TPerson).GetAttributes do
    if A is TableAttribute then
      Writeln(TableAttribute(A).Name);    // PEOPLE
end;