Transaction does not save

Posts   
 
    
Noer
User
Posts: 33
Joined: 04-Jan-2007
# Posted on: 07-Mar-2007 16:32:44   

Hi I have the following code:


Transaction manager = new Transaction(System.Data.IsolationLevel.ReadCommitted, "SynchronizeCustomerList");

try
            {
                 foreach (CustomerEntity customer in customerList)
                {
                        customer.ExportedDate = DateTime.Now;
                        manager.Add(customer);
                 }
            manager.Commit();       
            }
           catch
            {
                manager.Rollback();
                throw;
            }
            finally
            {
                manager.Dispose();
            }

How do I save the customers in transaction?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 08-Mar-2007 02:02:41   

You still need to call the entity's save method after adding it to the transaction. That way the commit will have an action to commit.


Transaction manager = new Transaction(System.Data.IsolationLevel.ReadCommitted, "SynchronizeCustomerList");

try
            {
                 foreach (CustomerEntity customer in customerList)
                {
                        customer.ExportedDate = DateTime.Now;
                        manager.Add(customer);
                        customer.Save();
                 }
            manager.Commit();       
            }
         catch
            {
                manager.Rollback();
                throw;
            }
            finally
            {
                manager.Dispose();
            }
Noer
User
Posts: 33
Joined: 04-Jan-2007
# Posted on: 08-Mar-2007 10:52:35   

I have tried that, but i doesn't save. If I debud and add a break-point at "manager.Commit(); " it never get that far. I dont get an error, it just stops debugging like everyting is OK.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 08-Mar-2007 15:31:46   

If I debud and add a break-point at "manager.Commit(); " it never get that far. I dont get an error, it just stops debugging like everyting is OK.

Strange, does it get to the catch block, or the finally block ? Is there anything showing in the output window.

You may try to enable tracing to get to see what's happening in LLBLGen Pro code. Refer to the LLBLGen Pro manual: "Using the generated code -> Troubleshooting and debugging"