Sometimes when we are troubleshooting issues, it's nice to look at the generated SQL statements. We can copy these out, execute them directly against the server, and find issues where we may have mistyped a value, flubbed a condition, or flipped a bit.
To make this configuration work, we just have to add the ShowSql
configuration property to our configuration, and set it to true
. In an inline configuration, the value would look as follows:
cfg.SetProperty( NHibernate.Cfg.Environment.ShowSql, "true");
This will add the SQL statements to our log4net loggers, which we can filter and direct, as necessary, from our configuration. If we add it to our existing Ordering.Console
application, the resulting logs will look similar to the following screenshot: