AuroraDbDbHelper

A helper class that is being used to retrieve the schema information (columns, primary/identity key) of an Aurora PostgreSQL table.

This class implements IDbHelper for Aurora PostgreSQL. It queries information_schema.columns (joined against pg_index to detect primary keys, and against pg_namespace to also recognize the session’s temporary schema) to build the list of DbField objects RepoDB uses internally to generate SQL statements.

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

Properties

Name Description
DbTypeResolver The IResolver<string, Type> used to convert an Aurora PostgreSQL column type name into its equivalent .NET CLR type. Defaults to AuroraDbDbTypeNameToClientTypeResolver.

GetScopeIdentity

GetScopeIdentity/GetScopeIdentityAsync execute SELECT lastval(); against the connection.

Retry on OperationInProgress

If the connection is already mid-operation, GetFields and GetScopeIdentity transparently retry once against a brand-new connection created from the same connection string. The failure is recognized by type name (NpgsqlOperationInProgressException) rather than by catching the Npgsql type directly, since AuroraDbConnection (RepoDb.Connector.AuroraDb.Npgsql) wraps NpgsqlConnection inside the AWS Advanced .NET Data Provider Wrapper.

Date/Time and Array Parameter Handling

After every ad-hoc parameter is created, this helper adjusts its value/DbType so it binds correctly against Aurora PostgreSQL:

  • A DateOnly value is converted to DateTime (midnight) with DbType.Date, and a TimeOnly value to TimeSpan with DbType.Time — neither has a direct binding on this connector.
  • A non-UTC DateTime value is bound as DbType.DateTime2, so its offset-naive value isn’t misread as UTC.
  • A DateOnly[]/TimeOnly[] array value has each element converted the same way (to DateTime[]/TimeSpan[]) before binding.

Usability

Only override this if you need a custom type resolver.

var dbHelper = new AuroraDbDbHelper(new MyCustomAuroraDbDbTypeNameToClientTypeResolver());
DbHelperMapper.Add<AuroraDbConnection>(dbHelper, true);