(流畅)NHibernate:映射 IDictionary
我找到了很多关于此的帖子,但似乎没有一个能直接帮助我。此外,在 FluentNHibernate 开发的不同阶段,解决方案是否有效似乎也存在混淆。
我有以下课程:
public class MappedClass
{
...
}
public enum MyEnum
{
One,
Two
}
public class Foo
{
...
public virtual IDictionary<MappedClass, MyEnum> Values { get; set; }
}
我的问题是:
- 我需要一个单独的(第三个)MyEnum 表吗?
- 如何映射 MyEnum 类型?我应该吗?
- Foo 的映射应该是什么样的?
我尝试过映射 HasMany(x => x.Values).AsMap("MappedClass")... 这会导致:NHibernate.MappingException:关联引用未映射的类:MyEnum
I've found a number of posts about this but none seem to help me directly. Also there seems to be confusion about solutions working or not working during different stages of FluentNHibernate's development.
I have the following classes:
public class MappedClass
{
...
}
public enum MyEnum
{
One,
Two
}
public class Foo
{
...
public virtual IDictionary<MappedClass, MyEnum> Values { get; set; }
}
My questions are:
- Will I need a separate (third) table of MyEnum?
- How can I map the MyEnum type? Should I?
- What should Foo's mapping look like?
I've tried mapping HasMany(x => x.Values).AsMap("MappedClass")...
This results in: NHibernate.MappingException : Association references unmapped class: MyEnum
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来这个问题是 用于映射 IDictionary? 的流畅代码的重复。解决方案是使用 hbm.xml 来映射三元关联表。看起来当时 FluentNHibernate 的 AsTernaryAssocation() 方法仅适用于实体类型。我不知道这是否已经改变,或者是否是一个计划中的功能。
It looks like this questions is a duplicate of Fluent code for mapping an IDictionary<SomeEntity, int>?. The solution was to use hbm.xml to map a ternary association table. It looks like at the time FluentNHibernate's AsTernaryAssocation() method only worked for entity types. I can't tell if this has changed, or if it is a planned feature.