I am using linq to Nhibernate to fire some select query to data base.
My question is, how do I know, the query generated by Fluent NHibernate?
I have found 4 options to know sql query in nhibernate and fluent nhibernate.
Intercepter - It is really good to see sql. we can put it in our Output of Visual Studio and even in log file.
ISessionFactory sf = Fluently.Configure()
.Database(MySQLConfiguration.Standard.ConnectionString(ConnectionString).ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf())
.ExposeConfiguration(c => c.SetInterceptor(new ABCInterceptor()))
.BuildSessionFactory();
public class ABCInterceptor : EmptyInterceptor
{
public override NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
{
Trace.WriteLine(sql.ToString());
return sql;
}
}