【发布时间】:2012-01-05 23:32:31
【问题描述】:
我在使用复合键时无法弄清楚如何映射接口。
我想要做的是:
interface Ifoo
{
int someInt {get;}
int id {get;}
}
class bar1: Ifoo
{
int someInt {get; protected internal set;}
int id {get; protected internal set;}
}
class bar2: Ifoo
{
int someInt {get; protected internal set;}
int id {get; protected internal set;}
}
class someOtherClass
{
Ifoo myFoo {get; protected internal set;}
int id {get; protected internal set;}
}
public class someOtherClassMap: ClassMap<someOtherClass>
{
CompositeId()
.KeyReference(x => x.myFoo, "fooID")
.KeyProperty(x => x.id, "id");
References(x => x.myFoo)
.Class(typeof (foo1))
.Class(typeof (foo2))
.Column("fooID")
.Not.Insert()
.Not.Update();
}
引用工作没有问题,但我无法让 KeyReference 工作,而且似乎没有任何“.Class”可以像引用一样使用。
我读到了:
Fluent NHibernate, working with interfaces
Programming to interfaces while mapping with Fluent NHibernate
这让我修复了引用问题,但我还没有找到解决 KeyReference 的方法。有什么明显的我遗漏的东西吗,因为我已经在谷歌上搜索了一段时间,到目前为止还没有找到任何东西。
【问题讨论】:
标签: nhibernate fluent-nhibernate nhibernate-mapping composite-id