Skip to content

Map Missing Properties To Null #34

@anshubhatnagar

Description

@anshubhatnagar

Consider following classes:

class PaperModel
{
    public int Id { get; set; }
    public int? PaperId { get; set; }
    public Paper Paper { get; set; }
}

class RockModel
{
    public int Id { get; set; }
    public int? RockId { get; set; }
    public Rock Rock { get; set; }
}

class Rock
{
    public int Id { get; set; }
}

class Paper
{
    public int Id { get; set; }
}

Now if we try to do the following:

var paperModel = new PaperModel();
var rockModel = new RockModel();

Mapper.Map(rockModel).Over(paperModel);

The property "Paper" of variable "paperModel" gets initialized when it is expected to be null.

This issue is similar to #21 however in this case both source and destination have missing target members.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions