Skip to content

Conversation

@maumar
Copy link
Contributor

@maumar maumar commented Jan 20, 2023

Problem was that we when accessing inner property on a JsonElement we used GetProperty. If property is not present (which should be allowed if we try to access optional navigation) KeyNotFound is thrown.

Fix is to use TryGetProperty instead to gracefully handle this scenario.

Fixes #30028

@maumar maumar requested review from a team and roji January 20, 2023 02:49
@maumar maumar changed the title Fix to #30062 - KeyNotFoundException on nullable nested object in JSON column if that object does not exist. Fix to #30028 - Added nullable property to Json mapped model resulting in errors instead of mapping non existing json property to null Jan 20, 2023
@ajcvickers
Copy link
Contributor

@roji Can you take a look at this? We're considering it for a patch.

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some possible simplifications but otherwise LGTM

…g in errors instead of mapping non existing json property to null

Problem was that we when accessing inner property on a JsonElement we used GetProperty. If property is not present (which should be allowed if we try to access optional navigation) KeyNotFound is thrown.

Fix is to use TryGetProperty instead to gracefully handle this scenario.

Fixes #30028
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Added nullable property to Json mapped model resulting in errors instead of mapping non existing json property to null

4 participants