-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not all members are being mapped #1417
Comments
Yeah, I don't see any other choice. One thing to look at is the TypeMap's MapExpression in debug mode. This is the map "plan" that will execute at runtime (you don't need to add the code directly). |
Also, use the AutoMapper.Net4 project if you're adding the code directly. |
You should be able to see the MapExpression without having to add AutoMapper. You should be able to open up IMapper or Mapper.Instance then go to Also you might want ReadableExpressions.Visualizers so you can actually read the expression generated. |
Or Configuration.FindTypeMapFor. And THERES that visualizer I was looking for lol |
Ok. Done that and we're approaching the culprit. The MapExpression for this particular object has only 4 out of 16 members mapped. The destintation (dto) has 16 members in total. The source (model) has 20. The MapExpression looks like this:
The configuration is simply:
So obviously the next question is: (On debuggind CreateMap, I can see that the mapping expression being created has the correct amount of DeclaredMembers for DestinationType and SourceType). So somwhere else down the line (whilst building the expression?) members are ignored. |
Hmmm and the source/dest types match? How about the reverse map? On Thursday, June 30, 2016, cryo75 notifications@github.com wrote:
|
Why is it creating a new Address when the map types are AddressModel and AddressDto? Is there some kind of Include call? |
@jbogard The reverse map looks correct as well. @TylerCarlson1 There are no include calls. I'm actually creating a new AddressModel instance manually to skip EF:
The actual mapping occurs in this method:
The Target property of the func variable always includes less members than those expected. |
What about a nice gist, and we'll do the debugging? :) |
@lbargaoanu Tried that but the mapping worked because I had only a couple of mappings. I will give it another try. |
I'm having a similar issue with 5.0. The mapping used to work with 4.2.1 but now doesn't. Here's the gist that reproduces the problem https://gist.github.com/qswinson/20262e54ff597b757d7500a82301f4a9 |
Where is GeoCoordinate? |
System.Device assembly. The example project contains a reference to it. |
A quick workaround is to disable constructor mapping if you don't use it. |
@cryo75 So what is Address object and does it have any CreateMap in your configuration. And if so can you tell us what they are. |
@lbargaoanu How do you disable constructor mapping? I'm not finding that in the documentation. |
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. |
After upgrading to 5.0.0 I have one model class (I've only tested this class so far) that has 4 members more than its dto class. Some members are other classes and some can be null or empty (if value types).
On mapping the model to the dto, only a couple of members are mapped. The remaining are all set to null.
On downgrading to 4.2.1, the mapping is successful. I've tried creating a gist for a repro but the gist works as expected with 5.0.0. However the test classes where not that complex as in my actual project.
As I cannot reproduce the error, would it be better to add Automapper into my project and debug the mapping?
The text was updated successfully, but these errors were encountered: