覆盖IAutoMappingOverride中的组件列

时间:2011-03-23 19:02:06

标签: fluent-nhibernate

我创建了一个如下所示的覆盖:

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");
    }
}

然而,这引发了一个例外:

System.InvalidOperationException: Tried to add 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()

我做错了什么?

1 个答案:

答案 0 :(得分:2)

这是Fluent NHibernate中的一个错误。我写了一个修复,但它还没有被接受

拉取请求位于:http://github.com/jagregory/fluent-nhibernate/pull/106