Cannot use .NET Type Enum for Discriminator Field

Posts   
 
    
EEnnis
User
Posts: 1
Joined: 18-Nov-2019
# Posted on: 18-Nov-2019 17:52:59   

Hello, our team is using LLBLGen 5.6.1 with .NET Core 3 as our target framework. We have set up a few tables for Table per Entity Hierarchy inheritance where B and C are sub-types of A.

We are trying to use our custom enum for the .NET type, mapped to an int target, but the field does not show up as an option when selecting the discriminator field.

I am confused by this behavior, as the documentation reads: "This column can be of any type, as long as it ends up as a non-nullable System.Byte/Int16/Int32/Int64/Guid/Decimal/Boolean or System.String type in LLBLGen Pro." https://www.llblgen.com/Documentation/5.6/Designer/Concepts/Inheritance.htm#physical-representation-in-the-relational-data-model-and-supported-discriminator-field-types

This makes me think that we should be able to use any .NET type as long as we are targeting one of the supported types. Am I misinterpreting this? Is it recommended to simply use an int or string for the .NET type?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 19-Nov-2019 13:18:54   

Discriminator fields aren't used by your own code, they're not set by your code for instance. So them being an enum is redundant, as their underlying type is int in general.

There's another detail which makes them a bit more cumbersome to use if they're an enum: the value, if it's an enum, first has to be converted to an instance of that enum before the materializer can perform the check which type to use to instantiate the data into.

Is there any specific reason you want to use an enum for this field?

Frans Bouma | Lead developer LLBLGen Pro