Skip to content

When mapping inner object to nullable property got property default value instead of null when the inner object is null #281

@yyounes

Description

@yyounes

When mapping inner object to nullable property got property default value instead of null when the inner object is null

Example:

class Program
    {
        static void Main(string[] args)
        {
            var result = new Child().Adapt<ChildResource>();
            Console.WriteLine(result.ParentId); //result.ParentId should be null not empty Guid
        }
    }


    public class Parent
    {
        public Guid Id { get; set; }
    }

    public class Child
    {
        public Guid Id { get; set; }
        public Parent Parent { get; set; }
    }

    public class ChildResource
    {
        public Guid Id { get; set; }
        public Guid? ParentId { get; set; }

    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions