4
votes

With Npgsql V3.0.3.0 I am adding a new record to a table which has a column in the database with type OID, which should map to UInt32 .Net type.

When executing the insert command the following exception is thrown "This .NET type is not supported in Npgsql or your PostgreSQL: System.UInt32".

The stack trace in the exception is:

at Npgsql.TypeHandlerRegistry.get_Item(Type type)
at Npgsql.TypeHandlerRegistry.get_Item(Object value)
at Npgsql.NpgsqlParameter.ResolveHandler(TypeHandlerRegistry registry)
at Npgsql.NpgsqlParameter.Bind(TypeHandlerRegistry registry)
at Npgsql.NpgsqlCommand.ValidateAndCreateMessages(CommandBehavior behavior)
at Npgsql.NpgsqlCommand.ExecuteNonQueryInternal()
at Npgsql.NpgsqlCommand.ExecuteNonQuery

The GetSchemaTable method from a DataReader on this table reports that the "Data Type" for the OID columns is UInt32.

1

1 Answers

5
votes

Since OID is a somewhat internal/non-standard field, Npgsql won't automatically write UInt32 as OID; you need to explicitly say you want to write an OID by setting the parameter's NpgsqlDbType field to Oid.