开发者

Linq to Sql: Change Conflict SQL Statement

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜