如何在流畅的nhibernate中将复合主键映射到外国?
我有下表:
table A:
FOO (PK) | CLIENT (PK)
table B:
BAR (PK) | CLIENT (PK/FK) | FOO (FK)
PK ->主键
FK->外键
A 和 B 之间存在一对多关系。 我不能简单地这样做:
class AMap
{
public AMap()
{
CompositeId().KeyReference(a => a.FOO)
.KeyReference(a => a.CLIENT);
HasMany(a => a.B);
}
}
class BMap
{
public BMap()
{
CompositeId().KeyReference(a => a.BAR)
.KeyReference(a => a.CLIENT);
References(a => a.A);
}
}
它会失败,但出现以下异常:
外键 (FKE7804EB3DA7EBD4B:B [FOO])) 的列数必须与引用的主键 (A [FOO, CLIENT]) 相同
是否可以使用流畅的nhibernate正确映射?
I have the following tables:
table A:
FOO (PK) | CLIENT (PK)
table B:
BAR (PK) | CLIENT (PK/FK) | FOO (FK)
PK -> primary key
FK -> foreign key
There's a one-to-many relation between A and B.
I can't simply do this:
class AMap
{
public AMap()
{
CompositeId().KeyReference(a => a.FOO)
.KeyReference(a => a.CLIENT);
HasMany(a => a.B);
}
}
class BMap
{
public BMap()
{
CompositeId().KeyReference(a => a.BAR)
.KeyReference(a => a.CLIENT);
References(a => a.A);
}
}
It will fail with the following exception:
Foreign key (FKE7804EB3DA7EBD4B:B [FOO])) must have same number of columns as the referenced primary key (A [FOO, CLIENT])
Is it possible to map this correctly with fluent nhibernate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了解决方案:
Found the Solution: