我有两张这样的桌子
CREATE TABLE [dbo].[TariffConfig]
(
PKey INT IDENTITY NOT NULL,
TariffDeterminatorCd INT NOT NULL
)
CREATE TABLE [dbo].[TariffDeterminator]
(
PKey INT IDENTITY NOT NULL,
Tariff INT NOT NULL
)
TariffDeterminatorCd 引用了来自 TariffDeterminator 的一行(它等于 TariffDeterminator 中的 PKey),但它们之间没有外键约束。
他们的实体类是这样的
public class TariffDeterminator : EntityBase
{
public virtual Int32 Age { get; set; }
public virtual Int32 Tariff { get; set; }
}
public class TariffConfig : EntityBase
{
public virtual TariffDeterminator Determinator{ get; set; }
}
我有一个像这样的 TariffDeterminator
public class TariffDeterminatorMap : EntityBaseMap<TariffDeterminator>
{
public TariffDeterminatorMap ()
: base()
{
this.Initialize("TariffDeterminator");
Map(x => x.Age).Not.Nullable();
Map(x => x.Tariff).Not.Nullable();
}
}
谁能帮我为 TariffConfig 实体编写 Fluent Nhibernate 映射?