Save a object list

Hi people.

How do I save a object list? Not one by one.

You have to save one by one. But that's just as simple as iterating through the list items and calling Save method for each of them.

But, how do i control the transaction?

one transaction for all object list.

IDBConnection property provides a BeginTransaction method that returns a IDBTransaction interface with Commit and Rollback methods:


Var
  Trans: IDBTransaction;
begin
  Trans := MyConnection.BeginTransaction; // MyConnection is IDBConnection
  Try
     //...
    Trans.Commit;
  Except
    Trans.Rollback; 
    Raise;
  End;
End;

As far as I see this won't work for inserting objects.
In class TInserter the transaction will be commited while this not happens in TDeleter or TUpdater. Is this intended?

I would prefer a way to run complex sequences of adding, updating and deleting objects within a transaction.

It should work with inserting as well. The transactions managed by IDBConnection can be nested.