我正在尝试使用 Fluent NHIbernate 关注这篇文章:http: //blogs.planetcloud.co.uk/mygreatdiscovery/post/Localizing-entities-with-NHibernate.aspx
我的测试产生以下错误:
----> NHibernate.MappingException : An association from the table TranslatedText refers to an unmapped class: .Domain.Localisation.ILocalizedEntity
知道如何让 NH 尊重界面吗?
添加.IncludeBase<ILocalizedEntity>()
到我的汽车模型中什么也没做……(正如预期的那样,它是一个接口而不是抽象的,对吧?)
映射:(问题)
mapping.HasMany(m => m.TranslatedTexts)
.AsSet()
.Inverse().Cascade.SaveUpdate()
.KeyColumn("EntityId")
.ForeignKeyConstraintName("none")
.Where("EntityClass = 'Domain.Question'");
翻译文本(有)public virtual ILocalizedEntity Entity { get; set; }
mapping.ReferencesAny(tt => tt.Entity)
.IdentityType<Guid>()
.EntityIdentifierColumn("EntityId")
.EntityTypeColumn("EntityType");
界面:
public interface ILocalizedEntity
{
ICollection<TranslatedText> TranslatedTexts { get; set; }
}
我在 FNH 测试套件中也看到了同样的情况。我有一种感觉,这与我使用 AutoMapping 的事实有关,但目前还不确定是什么......
确认编辑 - 使用标准 ClassMaps 而不是自动映射,具有上述相同的映射,按预期工作。