且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

您如何查看在LINQ to SQL中的SubmitChanges上导致错误的sql?

更新时间:2023-11-30 16:14:22

一种简单的方法是使用

A simple way to do this is to use the DataContext.Log property:

using (MyDataContext ctx = new MyDataContext())
{
    StringWriter sw = new StringWriter();
    ctx.Log = sw;

    // execute some LINQ to SQL operations...

    string sql = sw.ToString();
    // put a breakpoint here, log it to a file, etc...
}