dinsdag 3 februari 2009

Mapping of different NHibernate collection types to .Net

Today I had to create a many-to-many relationship with some attributes of its own in NHibernate. I ended up with a set construction with a composite type embedded, like shown on page 229 of Hibernate in Action.

That left me with one question: How to represent the <set> in .Net? There is no built-in Set type. However, NHibernate solved that by using the Iesi.Collection.dll, which is part of the NHibernate download. On the blog of rextang I learned this mapping:

<bag> IList
<list> IList
<set> Iesi.Collections.Iset (from the Iesi.Collections.dll assembly in the \bin folder of the NH distribution)
<map> IDictionary

And it works!

Geen opmerkingen: