Skip to content

Commit

Permalink
Update conceptual/Npgsql/release-notes/9.0.md
Browse files Browse the repository at this point in the history
Co-authored-by: Nino Floris <[email protected]>
  • Loading branch information
roji and NinoFloris authored Nov 19, 2024
1 parent 3e79e02 commit 1fa0bda
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion conceptual/Npgsql/release-notes/9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ See the [tracing documentation](/doc/diagnostics/tracing.html) for more informat
> [!NOTE]
> If you're using EF Core, the below pertains to the EF provider's [legacy POCO mapping](https://www.npgsql.org/efcore/mapping/json.html?tabs=data-annotations%2Cjsondocument#legacy-poco-mapping-deprecated), and not to the recommended [ToJson mapping](https://www.npgsql.org/efcore/mapping/json.html?tabs=data-annotations%2Cjsondocument#poco-mapping). Unfortunately, the latter does not yet support polymorphic serialization (support for this may be added in EF 10).
System.Text.Json has supported [polymorphic serialization](https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism) for a while, using a JSON `$type` property as the type discriminator. However, it was required that the `$type` property be at the top of the JSON document; this cause problems serializing to the PostgreSQL `jsonb` type, since that type does **not** preserve property order in JSON objects.
System.Text.Json has supported [polymorphic serialization](https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism) for a while, using a JSON `$type` property as the type discriminator. However, it was required that the `$type` property be at the top of the JSON document; this causes problems serializing to the PostgreSQL `jsonb` type, since that type does **not** preserve property order in JSON objects.

System.Text.Json 9.0 brings support for [out-of-order metadata reads](https://devblogs.microsoft.com/dotnet/system-text-json-in-dotnet-9/#out-of-order-metadata-reads), which is an opt-in feature allowing the `$type` property to be anywhere in the JSON object. When using Npgsql, you can opt into this when configuring your <xref:Npgsql.NpgsqlDataSourceBuilder> as follows:

Expand Down

0 comments on commit 1fa0bda

Please sign in to comment.