Char-Enumeration mapped to TIntegerField

Hi + tx for support!

I have

type
  [Enumeration(TEnumMappingType.emChar, 'A, M')]
  TModus = (mAutomatic, mManuell);
type
  TTBLXLSImport = class;
  [Entity]
  [Table('TBLXLSImport')]
  [Id('FID', TIdGenerator.IdentityOrSequence)]
  TTBLXLSImport = class
  private
   ...
    [Column('Modus')]
    FModus: TModus;

This is generated as Char(1) in the database. When I retrieve the field definitions from the BPL (yes recreated), a TIntegerFiels is created. Additionally, the FNCGrid (via Adapter) displays 0 for all NULLs.

What am I missing?

Char(1) is the data type for the database column.

The class member associated with that database column is an enumerated type. That's Delphi, and represents an ordinal (integer) value. That's why it appears as integer in TAureliusDataset. The dataset is a layer/binding for the object, not the database.
Finally, it display 0 as nulls because that's how you mapped it, the type of FModus is TModus. There is no way to store a null. You should replace it to:

FModus: Nullable<TModus>;

1 Like