Friday, November 18, 2011
In database programming we all typically do the same: create SQL statements, execute it in the database and retrieve results back, using a TDataset descendant object which we use to iterate through data.
I guess that just like most of you who work regularly with databases, we've all used or written at some point small, medium-size "frameworks" to make these tasks a little more simple. Functions that build the SQL statement automatically based on some parameters, client datasets that build update statements, data dictionaries, etc.. In the past months though, I have switched several large projects including projects of customers to a new framework, built from the ground up.
It's basically something that prevents you from writing code like this:
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]));
Invoice := Manager1.Find<TInvoice>(1); ShowMessage(Format('Invoice No: %d, Customer: %s, Country: %s', [Invoice.InvoiceNo, Invoice.Customer.Name, Invoice.Customer.Country.Name]));
We made it a generally useful ORM framework. We added a lot of features. We added lot of documentation, examples and demos. We tested it heavily with several databases and data-access components. We will release it very soon. And it's from TMS Software.
This blog post has received 47 comments.
Previous | Next | Index