Hi,
I'd like NHibernate to fill a collection on my class from a custom query. My setup is somewhat like this:
Class A has a one-to-many relation to Class B. B has two many-to-one relationships to Class C, From and To.
In Class B, I want to be able to map a collection of C instances, based on the From and To relations. The collection should contain all C instances that are in between From and To. If there is one older and one newer B instance that have semi-overlapping spans, the list of C instances for the older B instance should not contain the C instances that the newer B instance contains.
So, basically what I want to do is to map a Collection in B pointing to C with a custom WHERE clause. That WHERE clause joins in the B and A tables in order for me to make sure that the newer B instance "blocks" the collection for the older B instance. Is this at all possible in NHibernate?
I've looked at the Filter feature in NHibernate, but this is a "static" filter that always should run, not anything that varies dynamically, like the example with employees that are employed at a specified date.
Update: I've not found any good way. What I can do is to load all C instances for every B instance (there are not that many) and perform the filtering in-memory by a custom getter.