converting table-per-subclass to table-per-class-heirachy
Hello
The code for both is below, with commented lines being the attempt to
change the per-subclass into a class-
hierarchy strategy. The subclass mapping works in the sense that I do not get errors.
The error I get with my per-class-hierachy attempt is that the discriminator column cannot be null, which
is reasonable but I thought that NHib would populate the values in the
mapping (ie, "ACCOUNT" and "PROJECT").
Can someone please help do this?
Cheers,
Berryl
public class ActivityBaseMap : IAutoMappingOverride<ActivityBase>
{
public void Override(AutoMapping<ActivityBase> mapping)
{
mapping.IgnoreProperty(x => x.BusinessId);
mapping.IgnoreProperty(x => x.Description);
mapping.IgnoreProperty(x => x.TotalTime);
mapping.IgnoreProperty(x => x.UniqueId);
//mapping.DiscriminateSubClassesOnColumn("SubClassType");
}
}
public class AccountingActivityMap :
SubclassMap
{
public void Override(AutoMapping<AccountingActivity> mapping)
{
mapping.References(x => x.Account);
//DiscriminatorValue("ACCOUNT");
}
}
public class ProjectActivityMap : SubclassMap<ProjectActivity>
{
public void Override(AutoMapping<ProjectActivity> mapping)
{
mapping.References(x => x.Project);
//DiscriminatorValue("PROJECT");
}
}
I posted this at the google forum before I realized this forum was available and preferred, so please forgive the double posting.
Cheers,
Berryl
2 Posted by Berryl Hesh on 28 Mar, 2010 03:39 AM
I was missing the connection between telling FNH Automapping that I wanted to use Subclass strategy, as the big problem. The only thing that still looks off is the discriminator value, which is still the subclass Type and not the string value I set in the mapping.
Appreciate any feedback.
Cheers,
Berryl
AUTOMAP SETUP:
// shotgun approach for now m.Setup(s =>
MAPPING OVERRIDES: