Originally shared by David Berneda

Originally shared by David Berneda

Basic ORM (Object Relational Mapping) functionality is now possible with TeeBI. Next coming beta 7 will enable loading and manipulating custom classes and record structures into TDataItem objects.

This means we can use all TeeBI features with our own objects and records, like querying and summarizing, TBIDataset, TBIGrid, TBIChart, machine-learning algorithms, persistence to local disk or remote web access and so on.

Fields and/or properties, classes, records, records in records or classes in records, arrays, TList, TCollection etc are supported. Arrays are automatically managed as master-detail TDataItem relationships.

Example:

type
TCustomer=record
.... fields and properties... (can be records or classes too)
end;

var ORM : TTypeProvider; // generic
ORM := TTypeProvider.Create;

var Customers : TDataItem;
Customers:=TDataItem.Create(ORM);

// Fill example:
var MyData : Array of TCustomer;
MyData[23].Name := 'Acme Inc.' ....

ORM.Add( MyData )

// Get, Update, Clear, Remove, Find etc...
MyCustomer := ORM.Get(23);
ORM.Update(25, MyCustomer);
ORM.Remove( MyCustomer );
ORM.Clear;
ORM.Delete( 23 );

var Index : Integer;
Index := ORM.Find( MyCustomer );

// Now we can use Customers like any other TDataItem,
// for example:

BIGrid1.Data := Customers;


Speed is quite good, using internally Delphi RTL RTTI and TValue,
adding 100.000 records with many properties takes 0.6 seconds

Comments

Post a Comment