0
我見過如何使用舊的子類語法做到這一點的例子,但沒有使用較新的:SubclassMap語法。Fluent Nhibernate的嵌套子類
基本上,我有一個表中有多個鑑別器,需要弄清楚如何用FNH做到這一點。
感謝, 山姆
我見過如何使用舊的子類語法做到這一點的例子,但沒有使用較新的:SubclassMap語法。Fluent Nhibernate的嵌套子類
基本上,我有一個表中有多個鑑別器,需要弄清楚如何用FNH做到這一點。
感謝, 山姆
我們有一個基類用戶和許多派生類從學習者,評估人員,經理,管理員等
這裏是中userMap
public class UserMap : ClassMap<User>
{
public UserMap()
{
this.Id(x => x.Id);
this.Map(x => x.Active);
this.Component(
x => x.Address,
m =>
{
m.Map(x => x.Address1).Length(512);
m.Map(x => x.Address2);
m.Map(x => x.Address3);
m.Map(x => x.Address4);
m.Map(x => x.City);
m.Map(x => x.County);
m.Map(x => x.PostCode);
m.References(x => x.Country);
});
this.References(x => x.CreatedBy);
this.Map(x => x.CreatedDate).Not.Nullable();
this.Map(x => x.DeletedDate);
this.References(x => x.DeletedBy);
this.Map(x => x.Email);
this.Map(x => x.Fax);
this.Map(x => x.FirstName);
this.References(x => x.Gender);
this.Map(x => x.LastName);
this.Map(x => x.LoginName).UniqueKey("ui_loginName").Not.Nullable();
this.Map(x => x.MiddleName);
this.Map(x => x.Password);
this.DiscriminateSubClassesOnColumn("className").Length(64);
}
}
和經理的一個例子
public class ManagerMap : SubclassMap<Manager>
{
#region Constructors and Destructors
/// <summary>
/// Initializes a new instance of the <see cref="ManagerMap"/> class.
/// </summary>
public ManagerMap()
{
this.HasManyToMany(x => x.Organisation)
.ParentKeyColumn("userId")
.ChildKeyColumn("organisationId")
.Table("UserOrganisations");
this.HasMany(x => x.Learners)
.KeyColumn("managerId")
.AsBag();
}
#endregion
}
希望會幫助你。
你能舉幾個例子說明你如何使用它,以及你的實體是如何設計的? – 2010-05-05 10:08:24