Is it Necessary to add Rollback

Posts   
 
    
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 26-Oct-2013 06:04:49   

LLBLGEN 4.0 LLBLGEN Runtime Framework C# Windows App .Net Framework 4.0 SQL 2008 Server

Hi, In the below code, is it necessary to add "RollBack" as I have done or is it ok that I dont add Rollback and it rollsback by itself on failure ?


public static bool Delete(int titleid)
        {
            var transactionmanager = new Transaction(IsolationLevel.ReadCommitted, "MyTx");
            try
            {
                var title = new TitleEntity();
                title.Titleid = titleid;
                title.IsNew = false;
                title.Modifieddate = DateTimeClass.Currentdatetime();
                title.Flag = PublicConstantClass.Deletedflag;
                title.Modifieduserid = PublicConstantClass.Userid;
                var result = title.Save();
                transactionmanager.Commit();
                return result;
            }
            catch (Exception ex)
            {
                transactionmanager.Rollback();
                ErrorHandlerClass.LogMessage(ex.Message + ex.StackTrace);
                throw;
            }
        }

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Oct-2013 06:57:13   

Yes, it's. As long as you don't COMMIT or ROLLBACK a transaction, it's still "running" and potentially holding locks.

David Elizondo | LLBLGen Support Team
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 26-Oct-2013 08:00:44   

daelmo wrote:

Yes, it's. As long as you don't COMMIT or ROLLBACK a transaction, it's still "running" and potentially holding locks.

Thank you