2

By implementing ISubclassConvention, I can change the Discriminator Value for the subclasses in my class hierarchy. I'm now looking for a way to set the Discriminator Value for my base classes as well. Is there a way to change it with a convention override or do I have to add a manual mapping for my hierarchy?

(The IClassConvention provides the DiscriminatorValue property but it is read-only, so no luck there.)

Daniel Schilling
  • 4,829
  • 28
  • 60
Matthias Schippling
  • 2,923
  • 1
  • 18
  • 29

1 Answers1

2

The only way I know is to make simple mapping override just for base class.

public class DepotMappingOverride : IAutoMappingOverride<Depot>
{
    /// <summary>
    /// Alter the auto mapping for this type
    /// </summary>
    /// <param name="mapping">Auto mapping</param>
    public void Override(AutoMapping<Depot> mapping)
    {
        mapping.DiscriminateSubClassesOnColumn("Type", "BaseDepot");
    }
}

Now "BaseDepot" will be discriminator value for Depot class.

rodpl
  • 826
  • 8
  • 12