none
With the ADO.NET Providers, I'd like to be able to "preview" changes RRS feed

  • Question

  • That is, I'd like to run, but no actually do the update to the database.  Is there an event I can return something from, or some setting I can set to tell the ado.net provider to not actually do the work?  Or possibly intercept the transaction commit logic and simply roll it back?  Probably cancelling the transaction would be better because that would really simulate what will happen on the commit.

    Thanks


    Peter Kellner http://peterkellner.net Microsoft MVP • ASPInsider
    Monday, August 2, 2010 2:31 AM

Answers

  • if you just want to preview the change dataset, you might want to check it on the ChangesSelectedEvent, access the SyncContext.Dataset to check the changes and raise an exception to cancel the sync.
    Saturday, August 7, 2010 9:54 PM
    Moderator

All replies

  • I've found something that works, but not sure if it's right to get rollback.

    Here is my code to make all changes rollback.  Is it correct?

      void providerSource_ApplyingChanges(object sender, DbApplyingChangesEventArgs e)
          {
            e.Transaction.Rollback();
          }
    
          void providerDestination_ApplyingChanges(object sender, DbApplyingChangesEventArgs e)
          {
            e.Transaction.Rollback();
          }
    

    Peter Kellner http://peterkellner.net Microsoft MVP • ASPInsider
    Monday, August 2, 2010 2:46 AM
  • if you just want to preview the change dataset, you might want to check it on the ChangesSelectedEvent, access the SyncContext.Dataset to check the changes and raise an exception to cancel the sync.
    Saturday, August 7, 2010 9:54 PM
    Moderator