一个是使用Log去输出
http://stackoverflow.com/questions/4899974/how-to-view-linq-generated-sql-statements一个是使用SQL Server Profiler还有就是使用VS的第三方插件。

解决方案 »

  1.   

    连接打不开.
    VS咋就没有自带一个呢.这样出问题不知道语句是什么样的.不好调式.
    stackoverflow.com不是山寨网站,你稍微等下再看。
      

  2.   

    连接打不开.
    VS咋就没有自带一个呢.这样出问题不知道语句是什么样的.不好调式.
    stackoverflow.com不是山寨网站,你稍微等下再看。
    嗯,能复制过来.或直接告诉我解决方法吗?
    我用的是VS2013,自带没有能查看到SubmitChanges();提交到数据库的SQL语句吗?
      

  3.   

    连接打不开.
    VS咋就没有自带一个呢.这样出问题不知道语句是什么样的.不好调式.
    stackoverflow.com不是山寨网站,你稍微等下再看。
    嗯,能复制过来.或直接告诉我解决方法吗?
    我用的是VS2013,自带没有能查看到SubmitChanges();提交到数据库的SQL语句吗?I do this in my base for data access objects and output it to the Visual Studio debug console. As the objects create their DataContext I check it see if its debug and attach a TextWritter helper class like this:  dbDataContext _dB = new dbDataContext();
      _dB.CommandTimeout = 5000;#if DEBUG
        _dB.Log = new DebugTextWriter();
    #endif
    Here is the helper object for output to the debug console://utility class for output of TextWriter for the Visual Sudio Debug window
            class DebugTextWriter : System.IO.TextWriter
            {
                public override void Write(char[] buffer, int index, int count)
                {
                    System.Diagnostics.Debug.Write(new String(buffer, index, count));
                }            public override void Write(string value)
                {
                    System.Diagnostics.Debug.Write(value);
                }            public override Encoding Encoding
                {
                    get { return System.Text.Encoding.Default; }
                }
            }
    还有就是linqpad和linq to sql debug visualizer
    http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx
      

  4.   

    MessageBox.Show(this.SubmitChanges().ToString());//?不知道是否可行
      

  5.   

    到今天还是没有搞明白如何才能看到LINQ执行的代码到低是啥
      

  6.   

    http://www.cnblogs.com/jeffwongishandsome/archive/2010/11/03/1868438.html
      

  7.   

    SQL Server Profiler 看比较简单