tags:

views:

97

answers:

0

Update:
Turns out we were looking in the wrong place for a solution. Initially we were using only Configuration.ClassMappings and Configuration.CollectionMappings and as my original comments indicated, columns weren't being exposed from the CollectionMappings.

We found success (and the enumerations we wanted) when we worked through each ClassMapping's PropertyIterator and getting at the enumeration information differently based on whether the property was a Collection or a Component, Because there are several ways to map things using Components, this was by far the trickiest part. I'd like to blog in more detail about our solution. I'll try to post a link if/when this happens.



We are in the process of writing code to generate check constraints with all valid values from our enumeration mappings. Some of our enumerations are inside composite-elements through mapped set collections (see below):

<set name="Addresses" table="[Addresses$]" access="field.camelcase-underscore">
    <key column="Person" />
    <composite-element class="Address">
     <property name="StreetAddress1" column="[Street Address 1]" />
     <property name="Country" type="Import.DataAccess.Mappings.UserTypes.EnumerationDisplayNameType`1[[Core.Domain.Model.Enumerations.Country, Core]], Import" />
     <property name="State"  type="Import.DataAccess.Mappings.UserTypes.EnumerationDisplayNameType`1[[Core.Domain.Model.Enumerations.State, Core]], Import" />
     <property name="ZipCode" column="[Zip Code]" length="10" />
    </composite-element>
</set>

We can successfully get all the valid values for a particular enumeration using reflection when the enumerations are simply mapped as properties or inside components. We do this by getting NHibernate.Mapping.Table and iterate over the columns looking for our enumeration type. Our problem is with the collection types. The ColumnsIterator count is always zero for the collection types.

Has anyone been successful in getting column information from mapped sets (that happen to be value objects, if that matters at all) in code?

Not sure it's clear what we are trying to do. Let me know if there's more information needed to better understand the issue.

Any help here is much appreciated.

Thanks!