Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know query generated by Fluent NHibernate

Tags:

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?

like image 235
Rahul Somwanshi Avatar asked May 04 '09 06:05

Rahul Somwanshi


People also ask

What is fluent NHibernate?

Fluent NHibernate is another way of mapping or you can say it is an alternative to NHibernate's standard XML mapping files. Instead of writing XML (.hbm.xml files) documents. With the help of Fluent NHibernate, you can write mappings in strongly typed C# code. In Fluent NHibernate mappings are compiled along with the rest of your application.

How do I use LINQ with NHibernate?

NHibernate 3.0 introduces the Linq to NHibernate provider, which allows the use of the Linq API for querying with NHibernate. IQueryable queries are obtained with the Query methods used on the ISession or IStatelessSession. (Prior to NHibernate 5.0, these methods were extensions defined in the NHibernate.Linq namespace.)

How are IQueryable queries obtained in NHibernate?

IQueryable queries are obtained with the Query methods used on the ISession or IStatelessSession. (Prior to NHibernate 5.0, these methods were extensions defined in the NHibernate.Linq namespace.) A number of NHibernate Linq extensions giving access to NHibernate specific features are defined in the NHibernate.Linq namespace.

What is Hibernate Query Language (HQL)?

In this chapter, we will be covering Hibernate Query Language. HQL is shared across both Java's Hibernate and NHibernate. It is the oldest query mechanism along with Criteria. It was implemented very early and it is a string-based query API. You access it through ISession CreateQuery, and it is almost similar to SQL.


1 Answers

With Fluent NHibernate, you can turn on show_sql like this:

Fluently.Configure()     .Database( MsSqlConfiguration.MsSql2005.ShowSql().ConnectionString(...) )... 

NHibernate will now print every sql statement to Console.Out.

like image 97
Kevin Berridge Avatar answered Dec 28 '22 22:12

Kevin Berridge