Different querying methods
NHibernate supports more than one way of retrieving entities from database. These different ways are built at different times with each new implementation adding something new that was not present in the earlier methods. While new ways of querying entities added new features, in most cases, some of the existing features were also lost. In this section, we will try to get a quick overview of these different methods and understand the key differences between them.
Native SQL
NHibernate supports writing queries in native SQL supported by your database. While this feature is available, do not use it generously. Two main reasons this feature is provided are:
There is a need to utilize database specific features that are not exposed by other recommended querying methods, for example, query hints
You have a legacy SQL/ADO.NET-based application that you intend to migrate over to use NHibernate, so it is easier to use native SQL queries from existing application as is
Following...