These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: I'm a beginner. Please help me with IQuery
PostPosted: Sun Dec 24, 2006 1:25 am 
Newbie

Joined: Sun Dec 24, 2006 1:16 am
Posts: 2
Hi all !
I have a NHibernate question and really need your help.
i have 2 tables with one-to-many relation like this :
-tblCategories with these fields:
catID int primary key ( reference category field of tblItems)
catName nvachar(30);
catDesc nvarchar(100);
-tblItems with fields
itemID int primary key
category int
itemName nvarchar(50);
itemPrice double;
Now i create a IQuery like this
IQuery q=session.CreateQuery("Select item.ItemID,item.Name,item.Price
from Item as item,Categories as cat
where item.Category.catID = cat.catID and
cat.ID=:_inputID ");
This query executes OK but the problem is that i don't know how to get the result as the datasource
of a datagrid ( for example ). Can anyone help me???. I need it very much.
Thanks in advance
Merry chrismas and happy new year!!!


Top
 Profile  
 
 Post subject: Re: I'm a beginner. Please help me with IQuery
PostPosted: Sun Dec 24, 2006 9:35 am 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
senorali33 wrote:
Code:
IQuery q=session.CreateQuery("Select item.ItemID,item.Name,item.Price from Item as item,Categories as cat where item.Category.catID = cat.catID and cat.ID=:_inputID ");


This query will return an IList with object arrays that are not so easy to bind. What you need is a query that just returns the complete Item objects:

Code:
IQuery q=session.CreateQuery("select i from Item as i, Categories as cat where i.Category.catID = cat.catID and cat.ID=:_inputID ");

_________________
Cuyahoga


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 25, 2006 9:32 pm 
Newbie

Joined: Sun Dec 24, 2006 1:16 am
Posts: 2
thanks for your help but can you show me an example to bind the result with a gridview. sorry if this question is stupid. I'm a beginner.
Best regards!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.