[英]How can i set a Column in a CompositeId mapping with NHibernate
我有一個帶有NHibernate的復合Id映射,我想在所有Id中設置一個列。 這可能嗎?
public class MapProduction : ClassMap<Production>
{
public MapProduction()
{
CompositeId()
.KeyProperty(c => c.ProductionCode)
.KeyProperty(c => c.Cycle)
.KeyProperty(c => c.Crop)
.KeyProperty(c => c.TechnologyLevel);
Map(c => c.Area).Column("A_ARE");
Map(c => c.Productivity).Column("P_ARE");
Map(c => c.syncStatus).ReadOnly();
}
}
如果我只有一個id,我可以設置一個列,但復合我不能。
我怎樣才能做到這一點?
我發現了這個怎么做。 在CompositeId中有一個參數用於添加表引用。
public class MapProduction : ClassMap<Production>
{
public MapProduction()
{
CompositeId()
.KeyProperty(c => c.ProductionCode, "P_PRO")
.KeyProperty(c => c.Cycle, "C_CIC")
.KeyProperty(c => c.Crop, "C_CUL")
.KeyProperty(c => c.TechnologyLevel, "C_NVT");
Map(c => c.Area).Column("A_ARE");
Map(c => c.Productivity).Column("P_ARE");
Map(c => c.syncStatus).ReadOnly();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.