Mar 292012
 

TMS Software recently released a new framework for Delphi and Databases that is really quite neat.

Using the framework, you can reduce a lot of SQL needed as well as insert/post/update situations needed by wrapping around your object with the framework, which then ties then to a database and table.

For example:

type

TPerson = class
private
  FId: integer;
  FLastName: string;
  FFirstName: string;
  FEmail: string;
public
  property Id: integer read FId;
  property LastName: string read FLastName write FLastName;
  property FirstName: string read FFirstName write FFirstName;
  property Email: string read FEmail write FEmail;
end;

This is a typical simple class.

Now expand it with:

type

[Entity]

[Automapping]

TPerson = class
private
  FId: integer;
  FLastName: string;
  FFirstName: string;
  FEmail: string;
public
  property Id: integer read FId;
  property LastName: string read FLastName write FLastName;
  property FirstName: string read FFirstName write FFirstName;
  property Email: string read FEmail write FEmail;
end;

The TPerson class now is wrapped around Aurelius to allow database functionality.  So Saving a person is as simple as Manager.Save(Person).

Queries are also great and can be done in a couple ways, including Linq style queries such as:

PersonList := Manager.CreateCriteria<TPerson>;
.Where(TLinq.Like('FirstName', PersonName) or (TLinq.Like('LastName', PersonName)))
.AddOrder(TOrder.Asc('FirstName'))
.List;

What about common situations such as inheritance?  Not a problem. The inheritance still works the same way with the data storing in their perspective tables.

What databases are you limited to?  TMS Software’s Aurelius recently added support for my favorite database by Elevate Software called ElevateDB, but also supports the usual suspects such as MS SQL, MySQL, Oracle, SQLite, PostgreSQL, Interbase, Firebird and DB2.

If you haven’t yet, I’d encourage you to check out a demo on TMS Software’s website.