值对象列表的 Fluent NHibernate 约定是什么
我试图弄清楚值对象列表(在本例中为 IList)的约定是什么。这里是我的域模型的代码片段:
public class RegionSetting : Entity {
public virtual bool Required { get; set; }
public virtual string Name { get; set; }
public virtual IList<string> Options { get; set; }
}
我的自动映射设置为:
public class RegionSettingMap : IAutoMappingOverride<RegionSetting> {
public void Override(AutoMapping<RegionSetting> mapping) {
mapping
.HasMany(x => x.Options).Element("Options")
.Table("RegionSettingOptions")
.KeyColumn("RegionSettingId");
}
}
我想将 .Table()
和 .KeyColumn()
重写为约定,以便我不必在使用 IList
的所有地方都这样做。我认为我可以创建一个 IHasManyConvention
,但它似乎不会影响此映射。我在自定义 HasManyConvention
类中设置了一个断点,但它不会因 Options
属性而中断。谁能告诉我应该使用什么约定来自动执行此覆盖?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
IHasManyConvention
应该可以工作。尝试使用 IBagConvention,看看是否有效。如果没有,那就是里面有 bug。Using an
IHasManyConvention
should've worked. Try anIBagConvention
, see if that works. If not, there's a bug in there.