Inspection of Insert Statement When Using LINQ's SubmitChanges

Posted by Code Sherpa on Stack Overflow See other posts from Stack Overflow or by Code Sherpa
Published on 2010-06-02T20:18:52Z Indexed on 2010/06/02 20:24 UTC
Read the original article Hit count: 270

Filed under:
|
|
|

Hi.

I want to see what my insert statement would look like as if I was wiring up an text-based ADO.NET command. How do I do this?

I have been following the below link:

http://damieng.com/blog/2008/07/30/linq-to-sql-log-to-debug-window-file-memory-or-multiple-writers

And have added the DebugTextWriter class to my project. So, now, in my code I have the following which doesn't really do anything and I don't think its right:

    using(WorkbookDataContext dc = _conn.GetContext())
    {
        if(profile.ProfileId > 0)
        {
            dc.Profiles.Attach(profile, true);
        }
        else
        {
            dc.Profiles.InsertOnSubmit(profile);
        }

        dc.Log = new DebugTextWriter();

        #if DEBUG
            dc.Log = new System.IO.StreamWriter("linq-to-sql.log") 
            { 
                 AutoFlush = true 
            };
        #endif


        dc.SubmitChanges();
    }

Any ideas what I am doing wrong and/or how to inspect my LINQ insert statement correctly?

Thanks

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about debug