Skip to content

Query: We should throw when accessing non-nullable property over a null-value entity in the projection #20633

Closed

Description

@maumar

query:

ctx.Gears.Select(g => g.AssignedCity.Name.Length);

assuming assigned city can be null, we should throw "nullable object must have a value" (or ideally something more meaningful).

Currently we return default(int) - it might not be what user expected.
Casting result to nullable will yield correct result (and would get rid of the exception in the future)

ctx.Gears.Select(g => (int?)g.AssignedCity.Name.Length);

Activity

  1. changed the title [-]We should throw when accessing non-nullable property over a null-value entity in the projection[/-] [+]Query: We should throw when accessing non-nullable property over a null-value entity in the projection[/+] on Apr 14, 2020
  2. maumar commented on Apr 14, 2020

    @maumar
    ContributorAuthor

    Note: in 2.1 we would throw in this case, which we changed in 3.1. We want to go back to 2.1 behavior.

  3. self-assigned this
    on Apr 14, 2020
  4. added this to the 5.0.0 milestone on Apr 17, 2020
  5. ajcvickers commented on Apr 17, 2020

    @ajcvickers
    Contributor

    Notes from team discussion: we should do this alongside the other related change such that Sum queries still return correct values. Then I don't think this is a breaking change because it is only changing the result in places where it was previously wrong.

  6. added 3 commits that reference this issue on Jul 17, 2020
    078f68e
    4602ba3
    3ebfde7
  7. modified the milestones: 5.0.0, on Jul 18, 2020
  8. modified the milestones: , 5.0.0 on Nov 7, 2020
  9. added a commit that references this issue on Mar 5, 2021
  10. added a commit that references this issue on Mar 5, 2021
  11. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions