I have two tables:
CalendarEntry
Id
Date
...
Holiday
Id
Date
...
In my CalendarEntry class, I have a property like this
public ISet<Holiday> Holidays { ... }
which I want to associate to the Holiday instances that occur on the same Date as the CalendarEntry. However, I can’t come up with how to do this.
I’ve tried mapping it as one-to-many, but one-to-many automatically assumes that it should perform the join using CalendarEntry‘s Id column (presumably since it’s the only property that is guaranteed to be unique, which it must be to be one-to-many).
I’ve tried mapping it as many-to-many, but it seems that many-to-many requires a separate join table, which I don’t want in this case.
My question is: is it possible to map this in NHibernate, and how should I do it? If it’s not possible, why?
I think what you need to do is set up a query to get the Holiday entries. I’m not sure this can be done using a mapping.
Additional info from my original answer, which may not apply: You can have the many-to-many relationship in NHibernate without creating a separate entity class for the join table entries, but the underlying data still needs to exist somewhere in the database.