Linq to Sql get SqlCommand when stored procedure execution fails

Posted by Tim Mahy on Stack Overflow See other posts from Stack Overflow or by Tim Mahy
Published on 2010-06-03T11:29:59Z Indexed on 2010/06/03 11:34 UTC
Read the original article Hit count: 261

Hi all,

currently I'm assigning a TextWriter to the Log property of my Linq to Sql data context (per request instancing) and write this to my logging when an exception is thrown while executing a stored procedure (is strongly typed mapped in the context, so not executing a custom command)

however when using ADO.NET we normally inspect the SqlCommand upon unhandled exception to read out the parameters and log them

is it possible to access the SqlCommand that was used for executing a Stored Procedure in L2S so we can reuse that existing logging component? This would be far nicer than the current Log TextWriter solution....

greetings, Tim

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about stored-procedure