DEV Community

Cover image for Trysil - Delphi ORM
David Lastrucci
David Lastrucci

Posted on

Trysil - Delphi ORM

Perché continuare a scrivere codice così:

Query.SQL.Text :=
  'SELECT I.ID AS InvoiceID, I.Number, ' +
  'C.ID AS CustomerID, C.Name AS CustomerName, ' +
  'U.ID AS CountryID, U.Name AS CountryName ' +
  'FROM Invoices AS I ' +
  'INNER JOIN Customers AS C ON C.ID = I.CustomerID ' +
  'INNER JOIN Countries AS U ON U.ID = C.CountryID ' +
  'WHERE I.ID = :InvoiceID';
Query.ParamByName('InvoiceID').AsInteger := 1;
Query.Open;

ShowMessage(
  Format('Invoice No: %d, Customer: %s, Country: %s', [
    Query.FieldByName('Number').AsInteger,
    Query.FieldByName('CustomerName').AsString,
    Query.FieldByName('CountryName').AsString])); 
Enter fullscreen mode Exit fullscreen mode


Quando c'è la possibilità di scriverlo così?

LInvoice := FContext.Get<TInvoice>(1);
ShowMessage(
  Format('Invoice No: %d, Customer: %s, Country: %s', [
    LInvoice.Number,
    LInvoice.Customer.Name,
    LInvoice.Customer.Country.Name]));
Enter fullscreen mode Exit fullscreen mode

Per maggiori informazioni visitail link al progetto Trysil:

https://github.com/davidlastrucci/Trysil

Top comments (0)