Is there a way to make persistence of business objects with data from a database in Delphi 7? If possible without using components. Thank you for your advice.
+2
A:
You can use our Open Source ORM framework, using SQLite3 database. Full RESTful framework, works locally (i.e. in process), or remotely via HTTP/1.1, Named pipes or GDI messages. No external dll required. Works with Delphi 7 up to 2010.
All is done without any component, directly from source code. All database SQL is created from classes published properties.
For example, a People Table is defined in Delphi code as followed:
/// table used for the Babies queries
TSQLPeople = class(TSQLRecord)
private
fName: RawUTF8;
fAddress: RawUTF8;
fBirthDate: TDateTime;
published
property Name: RawUTF8 read fName write fName;
property Address: RawUTF8 read fAddress write fAddress;
property BirthDate: TDateTime read fBirthDate write fBirthDate;
end;
And you can access your data with code like this:
var People: TSQLPeople;
ID: integer;
begin
// create a new record, since Smith, Jr was just born
People := TSQLPeople.Create;
try
People.Name := 'Smith';
People.Address := 'New York City';
People.BirthDate := Now;
ID := Client.Add(People);
finally
People.Free;
end;
// retrieve record data
People := TSQLPeople.Create(Client,ID);
try
assert(People.Name='Smith');
finally
People.Free;
end;
end;
See http://blog.synopse.info/category/Open-Source-Projects/SQLite3-Framework
A.Bouchez
2010-08-05 15:11:15
A:
If you manage to get Bold for Delphi this is an excellent solution.
Roland Bengtsson
2010-08-13 05:18:04