views:

86

answers:

1

Hi

I am doing some work on an application that uses an existing schema that cannot be altered. Whilst writing my NHibernate mappings I encountered a strange many-to-many relationship. The relationship is defined in the standard way as in this question with the addition of a boolean flag on the association table that signifies if the relationship is legal. This seems somewhat redundant but as I say, cannot be changed.

Is it possible to define this relationship in Nhibernate without resorting to using a third class to represent the association? Perhaps by applying a filter?

Many thanks.

+3  A: 

This is something I run into quite a bit with NHibernate and keep coming back to the following resources. This article explains how you can create the Many-to-Many association and This Question shows how you can create the filter on your Many-to-Many without having to map the actual association class.

lomaxx
Fantastic. Thanks very much; it worked a treat.
Nigel
No problem. It's something I have to do often enough to know the resources, but not often enough to have committed it to memory yet :)
lomaxx