I have a `Rotation` class, which must contain references to multiple
lists of `Advert` objects. I would prefer an implementation where
`Rotation` has a property of type `List<List<Advert>>` to hold these,
but I am unable to come up with an NHibernate mapping supporting this.
In the database schema, the many-to-many relation between `Rotation`
and `Advert` is represented as a table `RotationAdvert` with the
following columns:
* RotationID
* AdvertID
* Variant ("horizontal position" / index within outer list)
* Position ("vertical position" / index within inner list)
The best solution I have found yet, is to implement a fixed number of
`List<Advert>` typed properties on `Rotation` and extend the mapping
with a `<list>` element for each:
<list name="Variant1" table="RotationAdvert" where="Variant = 1">
<key column="RotationID"/>
<index column="Position"/>
<many-to-many class="Advert" column="AdvertID"/>
</list>
<list name="Variant2" table="RotationAdvert" where="Variant = 2">
<key column="RotationID"/>
<index column="Position"/>
<many-to-many class="Advert" column="AdvertID"/>
</list>
etc...
However, this requires me to specify a fixed number of variants, which
I really would like to avoid.
What are my other options? Can I squeeze a `RotationVariant` class
into the model - without creating new tables in the database - and
somehow map a `List<RotationVariant> ` property on `Rotation`? Or will
I have to create a new table in the database, just to hold an ID for
each `RotationVariant`?
--
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.