Outputting SQL from NHibernate
I've added an interceptor to my Program, because it was not displaying any of the SQL in the SQL pane. I got the idea from here:
https://gist.github.com/rk4n/1242635
I made a small modification to the gist to make the output a bit more readable:
String output = Regex.Replace(sql.ToString(), "(FROM|INNER JOIN|WHERE|GROUP BY)", System.Environment.NewLine + "$1", RegexOptions.IgnoreCase);
output = Regex.Replace(output, @( as \w+, ), "$1" + System.Environment.NewLine + " " , RegexOptions.IgnoreCase);
log.Write(output);
Is there a better way to do this, maybe something that is supported by LinqPad?
I was reading about Custom Visualizers (http://www.linqpad.net/customvisualizers.aspx), but that is much more than I want to do, since I can run NHibernate Profiler to see the output cleanly.
Wondering if there is a way I can get nice output within LinqPad easily with just a SQL string.
Great product - I upgraded to premium today.
Thanks.
https://gist.github.com/rk4n/1242635
I made a small modification to the gist to make the output a bit more readable:
String output = Regex.Replace(sql.ToString(), "(FROM|INNER JOIN|WHERE|GROUP BY)", System.Environment.NewLine + "$1", RegexOptions.IgnoreCase);
output = Regex.Replace(output, @( as \w+, ), "$1" + System.Environment.NewLine + " " , RegexOptions.IgnoreCase);
log.Write(output);
Is there a better way to do this, maybe something that is supported by LinqPad?
I was reading about Custom Visualizers (http://www.linqpad.net/customvisualizers.aspx), but that is much more than I want to do, since I can run NHibernate Profiler to see the output cleanly.
Wondering if there is a way I can get nice output within LinqPad easily with just a SQL string.
Great product - I upgraded to premium today.
Thanks.
Comments
Cheers
Joe