GetChangeSet ChangeSet, Linq, what order of changes will be applied?

I am running the code to get the changeset just before the linq call change is pushed.

private void OnSubmitHandleReplication()
{
    System.Data.Linq.ChangeSet changes = GetChangeSet();
    //Do something with change set
}

      

In the "something" section, I need to know in what order things were sent and what order they will send to the database. I can see that the changeset has .Inserted, .Updated and .Deleted. I assume they are in the order they will be applied. However, I want to know the whole order. I guess it could be Insert, Update, then three more inserts or something to do with rolling back between these collections.

Update 1

Sorry thought the title was clear, Linq to SQL

Update 2

The reason I am doing this is to repeat them later in another DB.

0


a source to share


2 answers


It is quite difficult.

You will need to dig quite far into the reflection tracker to get the actual order.

As for the order of insert, update, delete, insert happens before deletion, so you need to watch out for unique constraints (which probably means you need to update instead of recreating).



EDIT

If you just need to "replay", you can use the logging feature.

0


a source


You can enable logging in Linq2SQL by setting YourDataContext.Log = Console.Out

or to any other compatible output stream. Every SQL query LINQ sends to the database will be printed there. You should only use this to debug your problem, because LINQ is sending quite a lot of requests :)



Edit: Regarding the order of things, I cannot help you further, I never looked at these requests any more than I should have.

0


a source







All Articles