Sam P
Sam P

Reputation: 127

How to return multiple rows in Nhibernate?

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?

Upvotes: 0

Views: 1453

Answers (1)

Claudio Redi
Claudio Redi

Reputation: 68410

Using Criteria API

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

Using HQL

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

Upvotes: 3

Related Questions