Link Search Menu Expand Document

PostgreSqlDbHelper


This class implements IDbHelper for PostgreSQL. It queries information_schema.columns (joined against pg_index for primary-key metadata) to build the list of DbField objects RepoDB uses internally to generate SQL statements.

It also resolves the newly generated identity value via SELECT lastval().

If the underlying NpgsqlConnection throws NpgsqlOperationInProgressException while a schema or identity query is issued (e.g. a prior command on the same connection is still streaming a result), the class transparently retries the operation on a new connection created from the same connection string.

It is automatically registered by PostgreSqlBootstrap — you do not need to instantiate it directly under normal use.

Properties

NameDescription
DbTypeResolverThe IResolver<string, Type> used to convert a PostgreSQL column data type (e.g. character varying) into its equivalent .NET CLR type. Defaults to PostgreSqlDbTypeNameToClientTypeResolver.

Usability

Only override this if you need a custom type resolver.

var dbHelper = new PostgreSqlDbHelper(new MyCustomPostgreSqlDbTypeNameToClientTypeResolver());
DbHelperMapper.Add<NpgsqlConnection>(dbHelper, true);