2
映射的複合ID比方說,我有以下3代表的現有數據庫:功能NHibernate從繼承複合標識
表1:
(PK)T1ID1
(PK)T1ID2
表2:
(PK)T2ID1
表3:
(FK)T1ID1
(FK)T1ID2
(FK)T2ID1 (其中3項來自上面的表)
我的問題是:如何映射表3與功能NHibernate?
什麼讓我感到困惑的是如何處理它的組合鍵來自2個不同的表。
我對映射表1和表2中的以下內容:
public class Table1
{
public virtual long T1ID1 { get; set; }
public virtual long T1ID2 { get; set; }
}
public class Table2
{
public virtual long T2ID1 { get; set; }
}
public class Table1Map
{
public Table1Map()
{
Table("Table1");
CompositeId()
.KeyProperty(x => x.T1ID1, "T1ID1")
.KeyProperty(x => x.T1ID2, "T1ID2");
}
}
public class Table2Map
{
public Table2Map()
{
Table("Table2");
Id(x => x.T2ID1, "T2ID1");
}
}
我有一些痛苦只是試圖映射m:n與兩個表複合pk。看起來並不像你的情況那麼優秀。運氣好的話? – 2010-02-02 10:13:46