Skip to content

Latest commit

Β 

History

History
86 lines (70 loc) Β· 2.06 KB

File metadata and controls

86 lines (70 loc) Β· 2.06 KB

5. ORM (Dext.Entity)

Dext.Entity is a full-featured ORM for Delphi with support for multiple databases.

Chapters

  1. Getting Started - First entity & context
  2. Entities & Mapping - Attributes and configuration
  3. Querying - Fluent query API
  4. Smart Properties - Type-safe queries without metadata classes
  5. JSON Queries - Query JSON/JSONB columns
  6. Specifications - Reusable query logic
  7. Relationships - 1:1, 1:N, Lazy Loading
  8. Migrations - Database schema lifecycle
  9. Scaffolding - Generate entities from DB
  10. Multi-Tenancy - SaaS data isolation

πŸ“¦ Examples:

Quick Start

// 1. Define Entity
type
  [Table('users')]
  TUser = class
  private
    FId: Integer;
    FName: string;
  public
    [PK, AutoInc]
    property Id: Integer read FId write FId;
    
    [Column('name')]
    property Name: string read FName write FName;
  end;

// 2. Create Context
type
  TAppContext = class(TDbContext)
  public
    function Users: IDbSet<TUser>;
  end;

// 3. Use It!
var
  Ctx: TAppContext;
  User: TUser;
begin
  Ctx := TAppContext.Create(Connection, Dialect);
  
  // Create
  User := TUser.Create;
  User.Name := 'John';
  Ctx.Users.Add(User);
  Ctx.SaveChanges;
  
  // Read
  User := Ctx.Users.Find(1);
  
  // Query
  var ActiveUsers := Ctx.Users
    .Where(function(U: TUser): Boolean
      begin
        Result := U.Name.Contains('John');
      end)
    .ToList;
end;

Supported Databases

Database Status
PostgreSQL βœ… Stable
SQL Server βœ… Stable
SQLite βœ… Stable
Firebird βœ… Stable
MySQL / MariaDB βœ… Stable
Oracle 🟑 Beta

← API Features | Next: Getting Started β†’