开发者

How to change NOCOUNT setting within LinqToSQL because of ChangeConflictException in Linq to Sql update

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开发者_JAVA百科 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?


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().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜