开发者

Linq to Sql: Change Conflict SQL Statement

开发者 https://www.devze.com 2023-03-06 18:21 出处:网络
When I catch a ChangeConflictExceptio开发者_StackOverflow中文版n is it possible to determine the actual SQL statement that failed from within the code?ie; rather than inspecting profiler output.I hope

When I catch a ChangeConflictExceptio开发者_StackOverflow中文版n is it possible to determine the actual SQL statement that failed from within the code? ie; rather than inspecting profiler output.


I hope I was not asking this question to attempt to perform some kind of optimistic concurrency re-syncing or reporting on fields (which is better performed via DataContext.ChangeConflicts). But anyhow...

You can access the SQL statements executed by the DataContext at anytime provided you log them via DataContext.Log. A very good tutorial of using this can be found here.

An example of writing this to file;

db.Log = new System.IO.StreamWriter("linq-to-sql.log") { AutoFlush = true };
0

精彩评论

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