Link Search Menu Expand Document

Db2GuidToByteArrayPropertyHandler


Db2 has no native GUID/UNIQUEIDENTIFIER type. The idiomatic Db2 storage for a GUID is a fixed-length 16-byte CHAR(16) FOR BIT DATA column.

This IPropertyHandler converts a Guid entity property to/from a byte[] for binding against such a column.

It is intentionally not registered automatically for every Guid property, since PropertyHandlerMapper registrations keyed by CLR type are global across the whole process — auto-registering it would also affect unrelated connections. Register it explicitly, scoped to the specific entity property that maps to a CHAR(16) FOR BIT DATA column, especially if your process also uses another RepoDb provider that handles Guid natively.

Usability

PropertyHandlerMapper.Add<CompleteTable, Guid>(
    e => e.SessionId, new Db2GuidToByteArrayPropertyHandler(), true);