views:

103

answers:

1

I'm trying to figure out what the convention would be for a value object list, in this case an IList. Here a code fragment for my domain model:

public class RegionSetting : Entity {
    public virtual bool Required { get; set; }
    public virtual string Name { get; set; }
    public virtual IList<string> Options { get; set; }
}

My automapping is set to:

public class RegionSettingMap : IAutoMappingOverride<RegionSetting> {
    public void Override(AutoMapping<RegionSetting> mapping) {
        mapping
            .HasMany(x => x.Options).Element("Options")
            .Table("RegionSettingOptions")
            .KeyColumn("RegionSettingId");
    }
}

I'd like to make the .Table() and .KeyColumn() overrides into a convention so that I don't have to do that everywhere I'm using IList<string>. I thought that I could create an IHasManyConvention, but it doesn't seem to affect this mapping. I set a breakpoint in my custom HasManyConvention class, but it doesn't break for the Options property. Could anyone tell me what convention I should be using to automate this override?

A: 

Using an IHasManyConvention should've worked. Try an IBagConvention, see if that works. If not, there's a bug in there.

James Gregory