Ordered many-to-many relationship in NHibernate

Posted by Kristoffer on Stack Overflow See other posts from Stack Overflow or by Kristoffer
Published on 2009-11-05T07:10:42Z Indexed on 2010/03/23 7:13 UTC
Read the original article Hit count: 458

Let's say I have two classes: Item and ItemCollection, where ItemCollection contains an ordered list of Item objects with an index, i.e. the list is ordered in a way specified by the user.

Let's also say that they have a many-to-many relationship, an ItemCollection can contain many items and an Item can belong to several ItemCollections.

That would, in my head, require three tables in the database. One for Item, one for ItemCollection and one for the ordered mapping. The mapping table would contain three columns:

int ItemID
int ItemCollectionID
int ListIndex

QUESTION: How would you design the ItemCollection class? Should the list of Item objects be a list, dictionary or other? What would the NHibernate mapping look like to get the ListIndex into the picture?

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about nhibernate-mapping