当我捕获ChangeConflictException时,可以确定代码中失败的实际SQL语句吗?IE;而不是检查分析器输出。

有帮助吗?

解决方案

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 };
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top