Da fällt mir z.B.
TMS Aurelius ein.
Statt
Delphi-Quellcode:
Query1.Sql.Text := 'SELECT I.ID AS INVOICE_ID, I.INVOICE_TYPE, I.INVOICE_NO, I.ISSUE_DATE, I.PRINT_DATE, ' +
'C.ID AS CUSTOMER_ID, C.CUSTOMER_NAME, C.SEX, C.BIRTHDAY, N.ID AS COUNTRY_ID, N.COUNTRY_NAME' +
'FROM INVOICE AS I INNER JOIN CUSTOMER AS C ON (C.ID = I.CUSTOMER_ID) ' +
'LEFT JOIN COUNTRY AS N ON (N.ID = C.COUNTRY_ID)' +
'WHERE I.ID = :INVOICE_ID;'
Query1.ParamByName('INVOICE_ID').AsInteger := 1;
Query1.Open;
ShowMessage(Format('Invoice No: %d, Customer: %s, Country: %s',
[Query1.FieldByName('INVOICE_NO').AsInteger,
Query1.FieldByName('CUSTOMER_NAME').AsString,
Query1.FieldByName('COUNTRY_NAME').AsString]));
schreibt man
Delphi-Quellcode:
Invoice := Manager1.Find<TInvoice>(1);
ShowMessage(Format('Invoice No: %d, Customer: %s, Country: %s',
[Invoice.InvoiceNo, Invoice.Customer.Name, Invoice.Customer.Country.Name]));
Ich wüßte jetzt nicht, warum
SQL hier das Leben einfacher machen sollte, es geht ja auch ohne (das
SQL im Vordergrund auftaucht)