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

ReverseMap ignores mapping inheritance (AutoMapper 5.1.1) #1743

Closed
dmdymov opened this Issue Oct 18, 2016 · 8 comments

Comments

Projects
None yet
3 participants
@dmdymov

dmdymov commented Oct 18, 2016

Gist with issue code.

ReverseMap ignores IncludeBase() calls. Everything works fine if you create separate reverse mapping.

@lbargaoanu

This comment has been minimized.

Show comment
Hide comment
@lbargaoanu

lbargaoanu Oct 18, 2016

Member

That's the way to go. ReverseMap won't do that for you.

Member

lbargaoanu commented Oct 18, 2016

That's the way to go. ReverseMap won't do that for you.

@dmdymov

This comment has been minimized.

Show comment
Hide comment
@dmdymov

dmdymov Oct 18, 2016

Won't do what? I mean what exactly does ReverseMap do then? My thought always was that it works exactly like separate reverse mapping. And this code works fine with AutoMapper 4.1.1.

dmdymov commented Oct 18, 2016

Won't do what? I mean what exactly does ReverseMap do then? My thought always was that it works exactly like separate reverse mapping. And this code works fine with AutoMapper 4.1.1.

@lbargaoanu

This comment has been minimized.

Show comment
Hide comment
@lbargaoanu

lbargaoanu Oct 18, 2016

Member

Well, it does copy some configuration, I'll investigate.

Member

lbargaoanu commented Oct 18, 2016

Well, it does copy some configuration, I'll investigate.

@dmdymov

This comment has been minimized.

Show comment
Hide comment
@dmdymov

dmdymov Oct 18, 2016

From gist:
CreateMap<ConcreteThingDto, ConcreteThing>()
.IncludeBase<ThingDto, Thing>()
.ReverseMap()
.IncludeBase<Thing, ThingDto>();

IncludeBase call after ReverseMap call is configuration here, isn't it?

dmdymov commented Oct 18, 2016

From gist:
CreateMap<ConcreteThingDto, ConcreteThing>()
.IncludeBase<ThingDto, Thing>()
.ReverseMap()
.IncludeBase<Thing, ThingDto>();

IncludeBase call after ReverseMap call is configuration here, isn't it?

@lbargaoanu

This comment has been minimized.

Show comment
Hide comment
@lbargaoanu

lbargaoanu Oct 18, 2016

Member

Actually it will copy Includes for you, but not IncludeBase. So apparently your example should work with Include, without any explicit configuration for the reverse map. But why IncludeBase is not similar, I don't know. I would say it's a bug.

Member

lbargaoanu commented Oct 18, 2016

Actually it will copy Includes for you, but not IncludeBase. So apparently your example should work with Include, without any explicit configuration for the reverse map. But why IncludeBase is not similar, I don't know. I would say it's a bug.

@dmdymov

This comment has been minimized.

Show comment
Hide comment
@dmdymov

dmdymov Oct 18, 2016

I am trying to upgrade my project to AM 5.1.1 and I have a lot of similar ReverseMap uses. Should I wait for a fix or CreateMap<B,A> is the solution?

dmdymov commented Oct 18, 2016

I am trying to upgrade my project to AM 5.1.1 and I have a lot of similar ReverseMap uses. Should I wait for a fix or CreateMap<B,A> is the solution?

@lbargaoanu

This comment has been minimized.

Show comment
Hide comment
@lbargaoanu

lbargaoanu Oct 18, 2016

Member

Wait. I didn't figure it out yet, but unless @jbogard disagrees, we'll fix it.

Member

lbargaoanu commented Oct 18, 2016

Wait. I didn't figure it out yet, but unless @jbogard disagrees, we'll fix it.

@jbogard

This comment has been minimized.

Show comment
Hide comment
@jbogard

jbogard Oct 19, 2016

Member

Nope, looks good.

Member

jbogard commented Oct 19, 2016

Nope, looks good.

@jbogard jbogard added the Improvement label Oct 19, 2016

@jbogard jbogard added this to the 5.2.0 milestone Oct 19, 2016

@jbogard jbogard closed this in #1746 Oct 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment