Your best bet is to start a transaction and do something like this:
-- Start a transaction so you can modify both tables without issuesBEGIN TRANSACTION-- Declare a temp variable to grab the row version from table1DECLARE @TEMPVERSION-- Retrieve the row versionSELECT @TEMPVERSION = RowVersion FROM Table1-- Check the row version to make sure that there isn't a concurrency issueIF @TEMPVERSION = @RowVersion THEN-- There isn't a concurrency issue, so update the tablesBEGIN-- Update Table1-- Update Table2-- Retrieve the @RowVersion to return it-- Committ the transaction because everything worked as expectedCOMMITTENDELSEBEGIN-- Rollback the transaction because there was a concurrency error-- The ROWCOUNT will automatically return 0 because no rows were -- updated and it will be detected by the business object as a -- concurrency errorROLLBACKEND
I'm not positive on all of the syntax, but it might get you started in the right direction.
Here's how my procedure logic is laid out.
When there are no concurrency issues, everything works great.However, if there is a problem during the table updates I do not receive an error.
I think this is more of a SQL Stored Procedure issue than anything having to deal with the framework but either way I'm not sure how to handle this. Any ideas?
TIA