What happens if I don't start transaction?

Posts   
 
    
Posts: 20
Joined: 03-Sep-2007
# Posted on: 17-Jan-2008 14:24:18   

Hi

I have an app which I have tightly kept control of transactions in (i.e. every chunk of code starts and commits a transaction.

What would happen if I got rid of the starttransaction / commit? I was concerned that this would result in a transaction being created for every entity that I try to save... is this the case?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 17-Jan-2008 14:57:01   

What would happen if I got rid of the starttransaction / commit? I was concerned that this would result in a transaction being created for every entity that I try to save... is this the case?

No, no StartTransactions would be used if you don't specify so.

From a database point of view every command is executed in an emplicit transaction, unless you explicitly started a transaction, and then you should take responsibility of commiting it or rolling it back.

Don't use transactions unless you need them, for example if you want to Insert an Order and its Order details but you want the entire transaction either to succeed or to fail. In this case you should use a Transaction, which should be commited or Rolledback accordingly.

LLBLGen Pro emplicitly uses Transactions for saving a graph of objects and/or entityCollections.

Posts: 20
Joined: 03-Sep-2007
# Posted on: 17-Jan-2008 15:29:28   

Thanks Walaa!

Does this not have an impact on performance (i.e. if every save happens in it's own transaction)?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 17-Jan-2008 15:34:07   

If you are speaking about implicit database transactions. No this won't affect performance as the transaction is commited at once.

What can affect performance is uncommited transactions. Or those which take long time before commiting them.

Posts: 20
Joined: 03-Sep-2007
# Posted on: 17-Jan-2008 15:56:08   

Brilliant! Many thanks for your reply!