`CreateMissingTypeMaps` doesn't work for destination object if source and destination types are the same
See original GitHub issueSource/destination types
class A
{
public string X { get; set; }
}
class B
{
public string X { get; set; }
}
Mapping configuration
var config = new MapperConfiguration(cfg => cfg.CreateMissingTypeMaps = true)
Version: 5.1.1
Expected behavior
I pass an existing object to be filled. The type of source and destination objects are the same. I expect the destination object to be filled.
Actual behavior
The destination object is not filled. If I use a different destination type, it works fine. If I create a new object of the same type, it also works fine.
Steps to reproduce
var config = new MapperConfiguration(cfg => cfg.CreateMissingTypeMaps = true);
var mapper = config.CreateMapper();
var a1 = new A { X = "sample" };
var a2 = new A();
mapper.Map(a1, a2); // a2.X was not set, looks like a bug
var a3 = mapper.Map<A>(a1); // a3.X is set, ok
var b = new B();
mapper.Map(a1, b); // b.X is set, ok
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Automapper doesn't fill destination object
I use Automapper with CreateMissingTypeMaps option set to true . If I try to fill an existing object of the same type, it...
Read more >AutoMapper — AutoMapper documentation
AutoMapper uses a convention-based matching algorithm to match up source to destination values. AutoMapper is geared towards model projection scenarios to ...
Read more >AutoMapper Documentation
First, you need both a source and destination type to work with. The destination type's design can be influenced by.
Read more >What is Automapper in C# and How to Use It
AutoMapper in C# is a library used to map data from one object to another in web development. It acts as a mapper...
Read more >AutoMapper.xml 4.2.1
Use this method when the source and destination types are not known until runtime. </summary> <param name="source">Source object to map from</param>
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I still don’t understand, is it some design limitation that blocks from implementing it or is there a logical reason why this particular case should not be supported?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.