An object-oriented representation of a NHibernate query.

Namespace:  NHibernate
Assembly:  NHibernate (in NHibernate.dll)

Syntax

Visual Basic (Declaration)
Public Interface IQuery
C#
public interface IQuery
Visual C++
public interface class IQuery
JavaScript
NHibernate.IQuery = function();
NHibernate.IQuery.createInterface('NHibernate.IQuery');

Remarks

An IQuery instance is obtained by calling ISession.CreateQuery(). This interface exposes some extra functionality beyond that provided by ISession.Iterate() and ISession.Find(); A particulare page of the result set may be selected by calling SetMaxResults(), SetFirstResult(). The generated sql depends on the capabilities of the Dialect. Some Dialects are for databases that have built in paging (LIMIT) and those capabilities will be used to limit the number of records returned by the sql statement. If the database does not support LIMITs then all of the records will be returned, but the objects created will be limited to the specific results requested. Named query parameters may be used

Named query parameters are tokens of the form :name in the query string. A value is bound to the Int32 parameter :foo by calling

 Copy Code
            	SetParameter("foo", foo, NHibernateUtil.Int32);
            
for example. A name may appear multiple times in the query string.

Unnamed parameters ? are also supported. To bind a value to an unnamed parameter use a Set method that accepts an Int32 positional argument - numbered from zero.

You may not mix and match unnamed parameters and named parameters in the same query.

Queries are executed by calling List() or Iterate(). A query may be re-executed by subsequent invocations. Its lifespan is, however, bounded by the lifespan of the ISession that created it.

Implementors are not intended to be threadsafe.

See Also