Trysil

4
3
Delphi 13

[TTable('Products')]
TProduct = class
strict private
  [TPrimaryKey]
  [TColumn('ID')]
  FID: TTPrimaryKey;

  [TColumn('Description')]
  [TRequired]
  [TLength(1, 100)]
  FDescription: String;

  [TColumn('Price')]
  FPrice: TTNullable<Double>;

  [TColumn('CategoryID')]
  FCategory: TTLazy<TCategory>;

  [TVersionColumn]
  [TColumn('VersionID')]
  FVersionID: TTVersion;
public
  property ID: TTPrimaryKey read FID;
  property Description: String read FDescription write FDescription;
  property Price: TTNullable<Double> read FPrice write FPrice;
  property Category: TTLazy<TCategory> read FCategory;
  property VersionID: TTVersion read FVersionID;
end;
var
  Products: TTObjectList<TProduct>;
begin
  Products := Context.Select<TProduct>(
    TTFilterBuilder<TProduct>.Create(Context)
      .Where('Price').GreaterThan(10.0)
      .AndWhere('Description').Like('%organic%')
      .OrderByAsc('Description')
      .Paging(1, 20)
      .Build
  );
end;