NHibernate Query object collection issue

Posted by Mahesh on Stack Overflow See other posts from Stack Overflow or by Mahesh
Published on 2010-05-19T17:21:48Z Indexed on 2010/05/19 23:10 UTC
Read the original article Hit count: 343

Filed under:
|
|

Hi,

I am new to NHibernate and need some information regarding the internal working of the engine:

I have a table called Student and the design is as follows:

RollNo
Name
City
Postcode

and there are 5 more columns like this. I have School class and mappings associated with it.

I am querying RollNo and Name using session as given below:

IQuery query = session.CreateQuery("SELECT RollNo,Name FROM Student);

Executing query.List resulting in error because the query is returning object[][].

Now, I changed the query as given below:

 IQuery query = session.CreateQuery("FROM Student);

Executing query.List on this query yeilds the desired results. But, the results contain more data than I want.

Could you please let me know the query to which I can get RollNo and Name from Student and castable as Student collection.

Thanks, Mahesh

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about object