Update before insert?

Posts   
 
    
Posts: 134
Joined: 10-Jan-2007
# Posted on: 18-May-2007 20:57:48   

I have a unique constraint on a table that uses a name + date field so that only one row can have a null date for that name. When I add a new row, I set the old current rows date to a value.

I am doing this in the same transaction, however, the insert of the new row happens before the update. Thus a unique key constraint error. Any way I can indicate to run the updates first?

Version 2.0.0.0 final SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll version 2.0.7.416

Brian Chance

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 18-May-2007 22:31:37   

I assume your using a UoW. the order of operations within the UoW is insert update delete this prevents duplicate key contstraint errors. (the scenario your in now)

you'll have to save them manually like this open connection keep connection open start transaction try update collection insert collection commit transaction catch rollback transaction finally close connection dispose connection