views:

28

answers:

1

Hi, I am new to Nhibernate. I want to retrieve collection of records against an entity. For example to retrieve a single record I have used the following statement:

resultObject=session.Get(id);

This above statement would retrieve a single record based on the 'id" I provide.

But I want to retrieve multiple rows from a table the way we retrieve from the following sql statement: Select * from Student

How can I do this using Nhibernate? Please guide?

+2  A: 

Using Criteria API

ICriteria criteria = session.CreateCriteria(typeof(Student));
criteria.List<Student>();

Using HQL

IQuery nhQuery = session.CreateQuery("FROM Student");
nhQuery.List<Student>()
Claudio Redi