Check out section 6.2 at 
http://www.hibernate.org/hib_docs/nhibernate/html/collections.html

Specifically, there is a "where" attribute that allows you to filter a mapped 
collection based on arbitrary sql.

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Henning
Sent: Monday, December 08, 2008 11:34 AM
To: nhusers
Subject: [nhusers] Filter collections


Hi,

I would like to filter the data that is being retrieved by NH from the
database. I have a class "projecttype", which holds a collection of
"projectsteps". But I only want to load those steps that are active.

So I figured I could define a filter in the mapping somewhere, so that
I don't have to do that in code. I remembered that there was a filter-
element inside of the bag-element. So I added

<filter name="onlyActive" condition="IsActive=true"></filter>

But I figured that I also need a filterdef element as well as I need
to enable filtering for the session. This might be a little tricky,
since I get my session from the NHibernateIntegrationFacility via
CastleWindsor. Also I don't actually need a named parameter, since my
filter-value would alwasy be constant.

Any thought on how to add a general filtering? Is the use of NH-
filters recommended? Is there a general way to enable filters?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to