NHibernate Query object collection issue
- by Mahesh
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