Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mapping CLR types to JSON at the type mapper level #2568

roji opened this issue Aug 14, 2019 · 0 comments


Copy link

commented Aug 14, 2019

Our current JSON support - both the older JSON.NET plugin and the newer System.Text.Json support introduced in #2306 - require you to manually specify NpgsqlDbType.{Json,Jsonb} on every parameter. In other words, it is currently not possible to map a user POCO type to json/jsonb at the global or connector level (the JSON.NET exposes an API for this, but it does not actually work for over a single type).

This is because our type mapping currently doesn't support a situation where more than one CLR type is mapped to the same PostgreSQL type.

Note: it will not be possible to have the user POCO returned by default when reading (i.e. without explicitly specifying it in GetFieldValue), since there's no way for us to distinguish between incoming JSON documents coming back from the database.

Another reason we need to allow mapping at the type mapper level, is in order to allow the user to specify JSON serialization options.

This is very related (and could be a dup of) #2439.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.