我使用Fluent NHibernate映射带有复合键的表。我想问一下是否有人知道未保存的DateTime的值应该是多少。 我写了#34; XXXXXXXX"在代码示例中应插入默认值。
我现在可以看到您只能设置一次未保存的值。如果为每个键设置它,则在Fluent创建hbm.xml文件时会出现错误。 所以我们需要在一个字符串中指定两个键值。
后端是Oracle,我正在映射到Date。
internal class BondRawAccruedDataMap : ClassMap<BondRawAccruedData>
{
public BondRawAccruedDataMap()
{
Schema("fpd");
Table("bond_accrued_raw_data");
CompositeId().KeyProperty(x => x.Instrument, "instrument").UnsavedValue("0")
.KeyProperty(x => x.RunDate, "run_date").UnsavedValue(DateTime.MinValue.ToString(XXXXXXXXXXXX));
Map(x => x.SettleDate, "settle_date");
Map(x => x.AccruedInterest, "accrued_interest");
Map(x => x.AccruedFactor, "accrued_factor");
Map(x => x.PrincipalFactor, "principal_factor");
Map(x => x.InterestDaysSinceCoupon, "days_acc");
}
}
更新了映射
internal class BondRawAccruedDataMap : ClassMap<BondRawAccruedData>
{
public BondRawAccruedDataMap()
{
Schema("fpd");
Table("bond_accrued_raw_data");
CompositeId().KeyProperty(x => x.Instrument, "instrument")
.KeyProperty(x => x.RunDate, "run_date").UnsavedValue("Unsaved value for instrument and rundate");
Map(x => x.SettleDate, "settle_date");
Map(x => x.AccruedInterest, "accrued_interest");
Map(x => x.AccruedFactor, "accrued_factor");
Map(x => x.PrincipalFactor, "principal_factor");
Map(x => x.InterestDaysSinceCoupon, "days_acc");
}
}