Filtering and sorting

Topic updated 13-6-2007

The NHibernate Templates use the NHibernate Framework's ICriteria querying interface. Most versions of the GetAll methods generated in Factory Classes take an ICriteria instance as an argument.

Please make sure you read and understand the NHibernate documentation about query criteria:

http://www.hibernate.org/hib_docs/nhibernate/html/querycriteria.html

The NHibernate Templates use custom HQL (with custom object instantiation) only when you define a Custom View in the Database Repository.

 

Custom Views

Custom Views are a special case. Internally the NHibernate Templates use HQL in combination with the dynamic object creation feature ("SELECT NEW") to retrieve a strongly typed HQL result. Because HQL can only work with IQuery instances, the NHibernate Templates translate the criteria (ICriterion) to make it compatible with HQL  / IQuery. As a result, you can write querying code the same way as for all other entities.