Link Search Menu Expand Document

ClientTypeToNpgsqlDbTypeResolver


This IResolver<Type, NpgsqlDbType?> implementation converts a .NET CLR type into its equivalent NpgsqlDbType (e.g. GuidUuid, Int32Integer, byte[]Bytea), including the Npgsql geometric and network-address types (e.g. NpgsqlPointPoint, IPAddressInet, PhysicalAddressMacAddr). It throws InvalidOperationException for a type it cannot resolve.

It is used by the PostgreSQL bulk operations (RepoDb.PostgreSql.BulkOperations) to determine the NpgsqlDbType of a column when writing via the binary importer.

Usability

var resolver = new ClientTypeToNpgsqlDbTypeResolver();
var npgsqlDbType = resolver.Resolve(typeof(Guid)); // NpgsqlDbType.Uuid