我在使用复合键时无法弄清楚如何映射接口。
我想要做的是:
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();
}
References 没有问题,但我无法让 KeyReference 工作,而且似乎没有任何“.Class”我可以像使用 References 一样使用。
我读:
使用 Fluent NHibernate 映射时对接口进行编程
这让我解决了引用问题,但我还没有找到解决 KeyReference 的方法。有什么明显的我失踪了,因为我已经在谷歌上搜索了一段时间,到目前为止还没有找到任何东西。