TylerCarlson1/AutoMapper — pull request #1 by TylerCarlson1 (2014-06-20 04:18:09+00:00)
Title: Inheritance Include with Unincluded inherited mappings

Issue has to do when using a mapping that have inherited classes on both source and destination have inheritance, but you are mapping with the destination being inherited from the base, but not included in the mappings.

What happens is the probable type maps then choose from list of maps based off the destinationType and not the actual type of the object. There is no issue with source Type because it uses the source's object to get the type.

I provided a failing unit test in first commit and solution in the second.

PS: The situation where I ran into this is when you map from one EF DbContext to another and the destination has inherited type mappings. You map both the base and the inherited and include the inherited in the type mapping, but when you map the base it will choose the inherited . This can't happen because both objects are actually DynamicProxy classes auto-generated by EF. You can't cast DynamicProxy_Base object to Inherited type, and can't get DynamicProxy type untill run time, if at all.