更新时间:2023-11-30 16:14:22
A simple way to do this is to use the DataContext.Log property:
using (MyDataContext ctx = new MyDataContext())
{
StringWriter sw = new StringWriter();
ctx.Log = sw;
// execute some LINQ to SQL operations...
string sql = sw.ToString();
// put a breakpoint here, log it to a file, etc...
}