开发者

Overriding component columns in IAutoMappingOverride

I have created an override that looks like this:

public class ProjectMappingOverride : IAutoMappingOverride<Project> {
    public void Override(AutoMapping<Project> mapping) {
        mapping.Component(p => p.OwnerNotifyReasons).ColumnPrefix("NotifyOwner");
        mapping.Component(p => p.ContactNotifyReasons).ColumnPrefix("NotifyContacts");
    }
}

However, this throws an exception:

System.InvalidOperationException: Tried to a开发者_运维技巧dd component 'OwnerNotifyReasons' when already added.
    d:\Development\FluentNHibernate\src\FluentNHibernate\MappingModel\MappedMembers.cs(134,0): at FluentNHibernate.MappingModel.MappedMembers.AddComponent(IComponentMapping componentMapping)
    d:\Development\FluentNHibernate\src\FluentNHibernate\MappingModel\ClassBased\ClassMappingBase.cs(115,0): at FluentNHibernate.MappingModel.ClassBased.ClassMappingBase.AddComponent(IComponentMapping componentMapping)
    d:\Development\FluentNHibernate\src\FluentNHibernate\Automapping\Steps\ComponentStep.cs(39,0): at FluentNHibernate.Automapping.Steps.ComponentStep.Map(ClassMappingBase classMap, Member member)
    d:\Development\FluentNHibernate\src\FluentNHibernate\Automapping\AutoMapper.cs(161,0): at FluentNHibernate.Automapping.AutoMapper.TryMapProperty(ClassMappingBase mapping, Member member, IList`1 mappedMembers)
    d:\Development\FluentNHibernate\src\FluentNHibernate\Automapping\AutoMapper.cs(149,0): at FluentNHibernate.Automapping.AutoMapper.<>c__DisplayClass13.<ProcessClass>b__12(Member x)
    d:\Development\FluentNHibernate\src\FluentNHibernate\Utils\CollectionExtensions.cs(15,0): at FluentNHibernate.Utils.CollectionExtensions.Each[T](IEnumerable`1 enumerable, Action`1 each)
    d:\Development\FluentNHibernate\src\FluentNHibernate\Automapping\AutoMapper.cs(147,0): at FluentNHibernate.Automapping.AutoMapper.ProcessClass(ClassMappingBase mapping, Type entityType, IList`1 mappedMembers)
    d:\Development\FluentNHibernate\src\FluentNHibernate\Automapping\AutoMapper.cs(43,0): at FluentNHibernate.Automapping.AutoMapper.MergeMap(Type classType, ClassMappingBase mapping, IList`1 mappedMembers)
    d:\Development\FluentNHibernate\src\FluentNHibernate\Automapping\AutoMapper.cs(176,0): at FluentNHibernate.Automapping.AutoMapper.Map(Type classType, List`1 types)
    d:\Development\FluentNHibernate\src\FluentNHibernate\Automapping\AutoPersistenceModel.cs(185,0): at FluentNHibernate.Automapping.AutoPersistenceModel.AddMapping(Type type)
    d:\Development\FluentNHibernate\src\FluentNHibernate\Automapping\AutoPersistenceModel.cs(153,0): at FluentNHibernate.Automapping.AutoPersistenceModel.CompileMappings()
    d:\Development\FluentNHibernate\src\FluentNHibernate\Automapping\AutoPersistenceModel.cs(175,0): at FluentNHibernate.Automapping.AutoPersistenceModel.Configure(Configuration configuration)
    d:\Development\FluentNHibernate\src\FluentNHibernate\Cfg\AutoMappingsContainer.cs(84,0): at FluentNHibernate.Cfg.AutoMappingsContainer.Apply(Configuration cfg)
    d:\Development\FluentNHibernate\src\FluentNHibernate\Cfg\MappingConfiguration.cs(74,0): at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
    d:\Development\FluentNHibernate\src\FluentNHibernate\Cfg\FluentConfiguration.cs(130,0): at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()

What am I doing wrong?


This is a bug in Fluent NHibernate. I'd written a fix, but it is not accepted yet.

The pull request is located here: http://github.com/jagregory/fluent-nhibernate/pull/106

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜