Fluent nHibernate 自动映射 - AutoMapping 覆盖问题
我刚刚尝试使用 Fluent Automapping 启动并运行一个项目(我熟悉 Fluent 但曾经编写每个映射)
我有一个对象 ScriptType ,它具有 ParseRules 属性,
public class ScriptType : EntityBase
{
public virtual string Name { get; set; }
public virtual IList<ParseRule> ParseRules { get; set; }
}
这被自动映射为 HasMany 和我想要参考文献。
因此,我向另一个程序集添加了 AutoMapping 覆盖...
public class ScriptTypeOverride : IAutoMappingOverride<ScriptType>
{
public void Override(AutoMapping<ScriptType> mapping)
{
mapping.References(x => x.ParseRules);
}
}
并更改了我的配置...
return configuration
.Mappings(m => m.AutoMappings
.Add(AutoMap.AssemblyOf<DatabaseInfo>()
.IgnoreBase<EntityBase>()
.Conventions.AddFromAssemblyOf<KeyConvention>()
.UseOverridesFromAssemblyOf<ScriptTypeOverride>()));
但我得到了这个.... :(
表 ScriptType 中的关联引用了未映射的类:System.Collections.Generic.IList `1[[GIT.ScriptWizard.Entities.ParseRule ...
任何人都可以帮忙吗?
I've just tried to get a project up and running with Fluent Automapping (I'm familiar with Fluent but used to write each of the maps)
I have an object ScriptType which has a ParseRules property
public class ScriptType : EntityBase
{
public virtual string Name { get; set; }
public virtual IList<ParseRule> ParseRules { get; set; }
}
This is being Auto Mapped as HasMany and I wanted References.
I therefore added an AutoMapping override to another assembly ...
public class ScriptTypeOverride : IAutoMappingOverride<ScriptType>
{
public void Override(AutoMapping<ScriptType> mapping)
{
mapping.References(x => x.ParseRules);
}
}
And altered my configuration as so ...
return configuration
.Mappings(m => m.AutoMappings
.Add(AutoMap.AssemblyOf<DatabaseInfo>()
.IgnoreBase<EntityBase>()
.Conventions.AddFromAssemblyOf<KeyConvention>()
.UseOverridesFromAssemblyOf<ScriptTypeOverride>()));
But I get this .... :(
An association from the table ScriptType refers to an unmapped class: System.Collections.Generic.IList`1[[GIT.ScriptWizard.Entities.ParseRule ...
Can anyone help please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 Fluent 网站。
你们的关系应该如何运作?它看起来像一个经典的
ScriptType
-to-manyParseRules
,所以这应该是ScriptType
上的HasMany
侧面,就像 Fluent 所做的那样。也许,如果您想在这里建立双向关系,其中
ParseRule
一侧是关系的“拥有”一侧,您应该在中使用
映射覆盖。Inverse()
ScriptType.ParseRulesFrom Fluent's website.
How should your relation work? It looks like a classic one
ScriptType
-to-manyParseRules
, so this should beHasMany
onScriptType
's side, as Fluent does.Maybe, if you want to have bidirectional relationship here, where
ParseRule
's side is the "owning" side of the relation, you should useInverse()
inScriptType.ParseRules
mapping override.