Data Access has been discontinued. Please refer to this page for more information.

How to: Set Advanced Properties

The purpose of this tutorial is to show you how to set advanced properties such as discriminator column and discriminator value when creating inheritance mapping.

For more information about how to implement inheritance with the Telerik Data Access Fluent Mapping API, please refer to the following topics:

Discriminator Column

Normally a discriminator column is required for flat and vertical inheritance. The discriminator column used to identify the type of each row with flat and vertical mapping is normally mapped to a SQL INTEGER but this can be changed. The default discriminator value for a class is a 32-bit positive hash of the fully qualified class name but this can also be changed. The name of the discriminator column can be changed, too.

The HasDiscriminatorColumn method exposed by the EntityMap class is obsolete. You should use the HasDiscriminatorColumn method of the MappingConfiguration<T> class.

Suppose, you have a sample FluentMetadataSource that models Flat Inheritance. When you update your database schema to the latest model state, an additional column named voa_class will be created. It will be used as a discriminator column.

The HasDiscriminator method specifies that the class will use an internal member for discriminator control. The HasDiscriminator method returns you a property configuration object that allows you to make an additional configuration for the internal field. For example, you could specify the name of the column that the discriminator member is mapped to. The following example shows you how to change the discriminator column name for the Animal class from the Flat Inheritance topic.

animal.HasDiscriminator().ToColumn("MyDiscriminatorColumn");
animal.HasDiscriminator().ToColumn("MyDiscriminatorColumn")

Now when you update your database, the discriminator column will be named "MyDiscriminatorColumn".

Discriminator Value

By default the discriminator value is a 32-bit positive hash of the fully qualified class name. The default discriminator value can be changed. To do that you should use the HasDiscriminatorValue method in the following manner.

animal.HasDiscriminatorValue("23");
animal.HasDiscriminatorValue("23")

The HasDiscriminatorValue method exposed by the EntityMap class is obsolete. You should use the HasDiscriminatorValue method of the MappingConfiguration<T> class.