UnitOfWork : Order of Execution

Posts   
 
   
 
Anonymous
User
Posts: 0
Joined: 11-Nov-2006
# Posted on: 05-Jun-2007 18:49:38   

Hi Guys,

I have a wizard thats collects user actions to a unit of work object and commits them. All in all, seems to be working quite well util I reach the following code:

                
//  delete current relationships                
IRelationPredicateBucket bucket = new RelationPredicateBucket(ProductVsCategoryFields.ProductId == entity.ProductId);
work.AddDeleteEntitiesDirectlyCall("ProductVsCategoryEntity", bucket); 
                
// create new relationships
foreach (int categoryid in categories)
{
ProductVsCategoryEntity category = new ProductVsCategoryEntity();                   
category.ProductId = entity.ProductId;
category.CategoryId = categoryid;
category.IsNew = true;
work.AddForSave(category);
}  

Independantly, the delete parts and the save parts work correctly but when used together the Saves are performed first and the Deletes afterwards. Is there anyway around this?

Cheers,

Th

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 05-Jun-2007 19:29:31   

This thread discusses similar issues:

http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=6694&HighLight=1

I ran in to a similar problem and ended up using a transaction instead of a UOW.

Anonymous
User
Posts: 0
Joined: 11-Nov-2006
# Posted on: 06-Jun-2007 01:16:32   

Hi there,

I stumbled across that thread also. Luckily I can code around it with a extra line or two in the controller but I was a little disappointed that I don't have more control over how the UoW is saved. Thanks for the link though,

Marcus, did you ever implement your own UoW object?

Cheers,

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39914
Joined: 17-Aug-2003
# Posted on: 06-Jun-2007 09:32:47   

This feature will be implemented in the upcoming upgrade simple_smile (was already planned).

Frans Bouma | Lead developer LLBLGen Pro
Anonymous
User
Posts: 0
Joined: 11-Nov-2006
# Posted on: 06-Jun-2007 10:19:52   

Great news. Thanks