none
How to inspect SQL Command of InsertOnSubmit? RRS feed

Answers

  • Use SQL Server Profiler. It allows you to see not only what sql is run but also the impact it has; I/O, CPU, locking etc etc.

     

    fyi - InsertOnSubmit, DeleteOnSubmit, updating objects etc will not run any SQL. All changes get queued up in the data context and will be executed when you call SubmitChanges.

    Tuesday, October 14, 2008 4:32 AM
    Answerer
  • You can use the Log property of the DataContext object to capture the SQL commands and parameters sent.

    http://damieng.com/blog/2008/07/30/linq-to-sql-log-to-debug-window-file-memory-or-multiple-writers shows how to send this to the debug window etc.

    You will see the insert statement and the parameters (they are parameterized queries for performance/security)

    [)amien
    Wednesday, October 15, 2008 1:58 AM
    Moderator

All replies

  • Use SQL Server Profiler. It allows you to see not only what sql is run but also the impact it has; I/O, CPU, locking etc etc.

     

    fyi - InsertOnSubmit, DeleteOnSubmit, updating objects etc will not run any SQL. All changes get queued up in the data context and will be executed when you call SubmitChanges.

    Tuesday, October 14, 2008 4:32 AM
    Answerer
  • >fyi - InsertOnSubmit, DeleteOnSubmit, updating objects etc will not run any SQL.
    >All changes get queued up in the data context and will be executed when you call SubmitChanges.

    Thank you for your information. Let me try the SQL Profiler. So can I inspect what is the SQL Command generated by InsertOnSubmit or so forth? I think it is more easy to analyse a single SQL Command instead of a lot of SQL Commands applied on SubmitChanges and I inspect them on this moment.

    Another question. I found that MS has a "SQL Trace". What is the different of its usage vs SQL Profiler?

    Thank you very much.
    Tuesday, October 14, 2008 7:50 AM
  • You can use the Log property of the DataContext object to capture the SQL commands and parameters sent.

    http://damieng.com/blog/2008/07/30/linq-to-sql-log-to-debug-window-file-memory-or-multiple-writers shows how to send this to the debug window etc.

    You will see the insert statement and the parameters (they are parameterized queries for performance/security)

    [)amien
    Wednesday, October 15, 2008 1:58 AM
    Moderator
  • Damien,

    Thank you. I think this is the answer what I want also.

    Diviner.
    Wednesday, October 15, 2008 3:00 AM