Link Search Menu Expand Document

DbTypeNameToColumnNameResolver


This IResolver<string, string> implementation converts a Firebird database type name — e.g. a DbField’s DatabaseType — into its equivalent base Firebird column type keyword (e.g. numericNUMERIC, varcharVARCHAR, binary/varbinaryCHAR/VARCHAR). Sized types (numeric, decimal, char, varchar, binary, varbinary) are returned without their (precision,scale)/(size) portion — the caller is expected to append that using the field’s own precision/scale/size.

It is used internally by RepoDb.Firebird.BulkOperations to generate the column definitions of the pseudo (staging) table backing BulkMerge, BulkUpdate, BulkDelete, BulkDeleteByKey, and BulkInsert with FirebirdBulkImportIdentityBehavior.ReturnIdentity. There, the base keyword this resolver returns is combined with the field’s Precision/Scale/Size (defaulting to 18/0/1 respectively when unset) and, for binary/varbinary, a trailing CHARACTER SET OCTETS — none of which this resolver appends itself.

An unrecognized or blob_text database type falls back to BLOB SUB_TYPE TEXT as a safe catch-all.

Usability

var resolver = new DbTypeNameToColumnNameResolver();
var baseType = resolver.Resolve("decimal"); // "DECIMAL"

// The caller appends sizing/charset itself, e.g.:
var columnType = $"{baseType}({field.Precision ?? 18},{field.Scale ?? 0})"; // "DECIMAL(18,2)"