3.5 Parent/Child Updates, Inserts and Deletes

3.5 Parent/Child Updates, Inserts and Deletes

Old forum URL: forums.lhotka.net/forums/t/4681.aspx


SouthSpawn posted on Saturday, April 12, 2008

I am trying to follow the project tracker for 3.5.
 
If I want to pass a Transaction from the parent to the child objects.

What is the proper way to do this?
 
I am using LINQ by the way.
 
This is what I did before.

For
Each item As Address In Me
      If item.IsNew Then
            
item.Insert( _
                  
Me, _
                  objTransaction)
      
Else
           
If item.IsDirty Then
               
item.Update( _
               
Me, _
               objTransaction)
            
End If
      End If
Next

Thanks,
Mark

RockfordLhotka replied on Sunday, April 13, 2008

The simplest approach is to use the Transactional attribute on the DP_XYZ method and say you want a TransactionScope.

Then use the new Csla.Data.ContextManager class to create/manage your LINQ data context object. The transaction is then automatically handled for you, as long as you allow an exception to bubble up in the case of failure (so TransactionScope knows to do a rollback).

SouthSpawn replied on Sunday, April 13, 2008

Rocky,
 
Can you give me some sample code for this.
I am looking at the project tracker, but I am a bit lost on how it is going through each item in the collection, then updating each one.
 
Any help would be great.

I simply can't put my finger on it.

Thanks,
Mark

SouthSpawn replied on Monday, April 14, 2008

Never mind,
 
I figured it out, all I have to say is wow.
 
That's awesome that is does a lot of the stuff for you.
 
Mark

SouthSpawn replied on Monday, April 14, 2008

bump

Copyright (c) Marimer LLC