'Npgsql 6.x: How to find type mapping for CLR Type

In one of my projects I'm migrating Npgsql from 5.x to 6.x and I noticed that Npgsql.NpgsqlConnection.GlobalTypeMapper is missing Mapping property.

In 5.x I was using this property to find CLR type and get it's mapping to Postgres Type Name (PgTypeName). Now (in 6.x), when Mappings property is gone, I need to do it in other way. So, how it is possible in Npgsql 6.x to map CLR Type to Postgres Type Name?



Solution 1:[1]

You can instantiate an NpgsqlParameter, set its value to something, and then check its DataTypeName property.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shay Rojansky