Go to file
Mark van Renswoude 8c25fa790b Renamed docs folder for ReadTheDocs compatibility 2020-09-13 23:05:08 +02:00
Packages Added List<> method 2020-09-13 22:53:17 +02:00
Source Added List<> method 2020-09-13 22:53:17 +02:00
UnitTests Added List<> method 2020-09-13 22:53:17 +02:00
docs Renamed docs folder for ReadTheDocs compatibility 2020-09-13 23:05:08 +02:00
.gitignore Renamed docs folder for ReadTheDocs compatibility 2020-09-13 23:05:08 +02:00
DaintyGroupDXE2.groupproj Proof of concept 2020-09-09 11:05:09 +02:00
LICENSE Initial commit 2020-09-09 10:56:46 +02:00
README.md Added List<> method 2020-09-13 22:53:17 +02:00

README.md

Dainty

Simple object mapper for Delphi

Heavily inspired by Dapper, Dainty aims to provide a lightweight layer to map objects from a TDataSet descendant or to TParams. It is intentionally not a fully fledged ORM framework.

Documentation is available on ReadTheDocs.

Quick examples

Iterating through a dataset:

for customer in query.Rows<TCustomerRow> do
  SendEmail(customer.FullName, customer.Email);

Getting a list of objects:

customers := query.List<TCustomerRow>;
try
  { ... }
finally
  FreeAndNil(customers);
end;

Getting a single row from a dataset:

customer := query.GetFirst<TCustomerRow>;
try
  { Alternatively: GetFirstOrDefault, GetSingle, GetSingleOrDefault }
finally
  FreeAndNil(customer);
end;

Assigning parameter values:

type
  TCustomerParams = class
  public
    FullName: string;
    Active: Boolean;
  end;

...

query.SQL.Text := 'select CustomerID, FullName, Active from Customer ' +
                  'where FullName = :FullName and Active = :Active';

customerParams := TCustomerParams.Create;
try
  customerParams.FullName := 'John Doe';
  customerParams.Active := True;

  query.Params.Apply(customerParams);
  query.Open;

  { ... }
finally
  FreeAndNil(customerParams);
end;