UnitOfWork: Delete first, then Update/Insert

Posts   
 
    
Alexander
User
Posts: 8
Joined: 13-Jul-2007
# Posted on: 13-Nov-2007 12:26:23   

Hello, I'm using a UnitOfWork to delete all records in a Table and then Inserting new Records. I do it this way:

// 1. Deleting all
ProjectEntity project = new ProjectEntity("0815");

uow.AddDeleteMultiCall(project.CustomerProject, new PredicateExpression(CustomerProjectFields.ProjectId == project.ProjectId));

//2. Inserting new one

CustomerProjectEntity customerProject = project.CustomerProject.AddNew();
customerProject.Project = project; //= ProjectEntity
customerProject.Customer = customer; //= CustomerEntity

uow.AddForSave(customerProject);

Unfortunately UOW first do INSERT then DELETE, so all new inserted Records will be deleted the next second an my Table/Collection always is empty.

Is it possible to tell UOW to do first all DELETE-Statements and then INSERTING/UPDATE ?

Thank's for your help,

Alex

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 13-Nov-2007 12:37:36   

In v.2.5 you can change the order of executions of a UoW.

Please check Specifying the order in which the actions are executed, in the manual under "using the generated code -> Adapter/SelfServicing -> Unit of work and field data versioning"

Alexander
User
Posts: 8
Joined: 13-Jul-2007
# Posted on: 14-Nov-2007 11:11:59   

Walaa wrote:

In v.2.5 you can change the order of executions of a UoW.

That's great - thank you very much! I just updates to v.2.5 - and it solves my problem!smile