I made a simple implementation for logging NHibernate queries in Visual Studio's output window, without use of third party loggers.
Create an interceptor class, and override one method
public class NHLogger : EmptyInterceptor, IInterceptor { public override NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql) { System.Diagnostics.Debug.WriteLine("NHIBERNATE: " + sql); return base.OnPrepareStatement(sql); } }
Then create an instance of it in the OpenSession of the Factory.
SessionFactory.OpenSession(new NHLogger());
1 comment:
The ultimate goal of engineering research writing services is to provide Engineering Assignment Writing Services and engineering coursework writing services since engineering dissertation help seekers lack time to complete their custom engineering research papers.
Post a Comment