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
Is it possible to create a mapping per type discriminator? #258
Comments
I wonder if it could be part of the Include option? |
Yeah, having a Where() on the Include option would be excellent! |
it would be awesome. is there any solution for this situation right now? |
Added pull request to add this feature in #590. It's not a Where() but an IncludeOnSourceCondition() right now. Also another note about this change. You will NOT be able to use this for projection at the moment. Entity Framework at least, because it doesn't support casting return types when you project. |
I just posted a question on StackOverflow related to the problems I'm having with mapping based on a property of the original model in a inheritance scenario. Jimmy, I'm sure my problem is related to this. Could you perhaps take a look at that and suggest some workaround? |
It is related to this and unfortunately there's nothing you can do with includes to make this work. Fix for this issue in code shown here 3ed6d8a as part of #590 |
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. |
Something like this:
Mapper.CreateMap<DTO.Party, Party>();
Mapper.CreateMap<DTO.Party, SomeParty>().Where(source => source.PartyTypeDiscriminatorValue == 1);
Mapper.CreateMap<DTO.Party, SomeOtherParty>().Where(source => source.PartyTypeDiscriminatorValue == 2);
var party = new DTO.Party() { PartyTypeDiscriminatorValue = 2 };
var result = Mapper.Map<DTO.Party, Party>(party);
Assert.IsTrue(result is SomeOtherParty)
The text was updated successfully, but these errors were encountered: