3

I am experiencing exactly this problem (and am in exactly the same world of pain): ChangeConflictException in Linq to Sql update

Whereby I am offering an update to SQL using LinqToSQL and it is failing with a ChangeConflictException because NOCOUNT is set to ON.

Due to legacy databases also on the server I am targeting, I am not able to re-configure the default connection settings as is quite rightly stated in the accepted answer in ChangeConflictException in Linq to Sql update.

My question is: How do you convince LinqToSQL to run a SQL SET NOCOUNT OFF before executing an update?

Community
  • 1
  • 1
Don Vince
  • 1,282
  • 3
  • 18
  • 28

1 Answers1

6

Here is a trick.

You can use ExecuteQuery method (from DataContext object) to execute something like ExecuteQuery<int>("SET NOCOUNT OFF SELECT 1"); and after that you can set the new property/properties for your object(the one you wanted to update) and call SubmitChanges().

Arabela Paslaru
  • 6,754
  • 1
  • 15
  • 10