code_junkie

How can you see the sql that is causing an error on SubmitChanges in LINQ to SQL?

Nov 11th, 2011
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. using (MyDataContext ctx = new MyDataContext())
  2. {
  3. StringWriter sw = new StringWriter();
  4. ctx.Log = sw;
  5.  
  6. // execute some LINQ to SQL operations...
  7.  
  8. string sql = sw.ToString();
  9. // put a breakpoint here, log it to a file, etc...
  10. }
  11.  
  12. context.GetChangedSet();
Add Comment
Please, Sign In to add comment