views:

103

answers:

0

Below is an example of how I currently use automapping overrides to set up a my db representation of inheritance. It gets the job done functionality wise BUT by using some internal default values. For example, the discriminator column name winds up being the literal value 'discriminator' instead of "ActivityType, and the discriminator values are the fully qualified type of each class, instead of "ACCOUNT" and "PROJECT".

I am guessing that this is a bug that doesn't get much attention now that conventions are preferred, and that the convention approach works correctly. I am looking for a sample of usage.

Cheers,
Berryl

    public class ActivityBaseMap : IAutoMappingOverride<ActivityBase>
{
    public void Override(AutoMapping<ActivityBase> mapping)
    {
        ...
        mapping.DiscriminateSubClassesOnColumn("ActivityType");
    }
}

public class AccountingActivityMap : SubclassMap<AccountingActivity>
{
    public AccountingActivityMap() {
        ...
        DiscriminatorValue("ACCOUNT");
    }
}

public class ProjectActivityMap : SubclassMap<ProjectActivity>
{
    public ProjectActivityMap() {
        ...
        DiscriminatorValue("PROJECT");
    }
}