Skip to content

Automapper keeps closing the issues related to Nullable source to Non-Nullable destination mapping #4627

Description

@MarioVolarevic

This is a problem which has been present from 2018 and still hasn't been solved, which is very useful for the PATCH scenarios.
I won't write steps to reproduce because you can see them in the linked issues:

#2918
#2999
#3926
#4530

Amd you keep closing all similar issues, when there is obviously a need to support this behaviour.
It's even missing in the documentation so it has to be discovered each time by a new individual.

Activity

  1. jbogard commented on Apr 2, 2026

    @jbogard
    Contributor

    All the previous issues are before the commercial fork (which we've kept for posterity). The previous versions were provided as-is, with no support. Now that commercial backing and support exists, we can revisit these issues.

    Just as an aside, we're going through ALL the older "closed won't fix" issues to prioritize fixes for common issues, like this one.

    We'll take a look!

  2. jbogard commented on Sep 4, 2026

    @jbogard
    Contributor

    Took a look. There are two things tangled together here:

    1. dest.Int = src.NullableInt ?? default(int) with no condition is inherent — a name match always produces an assignment and a non-nullable destination member has no way to represent absence. Not fixable, but it was undocumented.
    2. The Condition source member argument was a real bug. It is documented as the source member, but we passed the value after conversion to the destination member type, so null had already collapsed to default(T) before your condition ran. That is what made the PATCH scenario unexpressible.

    #4655 fixes (2) and documents (1). Reopened #2918, #2999, #3926 and #4530 to track.

  3. added this to the 16.3.0 milestone on Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions