Multiple ORM statements in one transaction

Home Forums kbmMW Multiple ORM statements in one transaction

This topic contains 1 reply, has 2 voices, and was last updated by  kimbomadsen 2 weeks, 2 days ago.

  • Author
    Posts
  • #54205

    mrluigi2017
    Participant

    Hi,

    How can I use the same transaction for multiple orm methods? I saw that I can pass a transaction, but I don’t know how to obtain it.

    Thanks in advance.

    Kind regards,

    Luigi

  • #54213

    kimbomadsen
    Keymaster

    Hi,

    var
    tx:TkbmMWTransaction;
    begin
    tx:=TkbmMWTransaction.Create;
    try
    tx.StartTransaction;
    try
    ORM.Insert(data,…,tx);
    ORM.Insert(data2,…,tx);
    tx.CommitTransaction;
    except
    tx.RollbackTransaction;
    end;
    end;

    best regards

    Kim/C4D

You must be logged in to reply to this topic.