Trysil - Delphi ORM

davidlastrucci

David Lastrucci

Posted on February 19, 2024

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

💖 💪 🙅 🚩
davidlastrucci
David Lastrucci

Posted on February 19, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Trysil - Multi-tenat API REST
trysil Trysil - Multi-tenat API REST

November 26, 2024

Trysil - TWhereClause
trysil Trysil - TWhereClause

February 19, 2024

Trysil - Delphi ORM
trysil Trysil - Delphi ORM

February 19, 2024