How to dynamically modify NHibernate load queries at runtime? EventListeners? Interceptors?

Posted by snicker on Stack Overflow See other posts from Stack Overflow or by snicker
Published on 2010-03-17T16:43:13Z Indexed on 2010/03/17 17:11 UTC
Read the original article Hit count: 265

Filed under:
|
|
|

I need to modify the query used to load many-to-one references in my model.

Specifically, I need to be able to further filter this data. Unfortunately, NH will not allow me to filter many-to-one relationships using the built in filtering system (?). I could just be doing something incorrect.

Is there a hook where I can manually and dynamically modify the query used to load the data? Or an alternative to filters that will allow me to specify parameters?

Background:

I am working with a database that is using a form of revision control, with each entity having a natural ID PK, an EntityId, a RevisionValidTo and RevisionValidFrom field. There may be many rows using the same EntityId, which is the reference for other tables to join on, but the Revision ranges are mutually exclusive. Thus, the relationship is only many-to-one IIF the filter is applied. However, NH offers no way to specify a filter on many-to-one references (they do for collections...)

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET