Inheritance Include with Unincluded inherited mappings #537

wants to merge 8 commits into


None yet
2 participants

TylerCarlson1 commented Jun 20, 2014

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.

jbogard and others added some commits Feb 18, 2013

Fixes issue without failing and current unit tests.
Note: Line 383 is completely useless giving 382 and 379 are identical and both will be anded together
Just accounted for the fact when destination exists, use destination's type instead of the typemap's destinationtype to account for this issue when looking into includes

jbogard commented Jul 8, 2014

This is getting complicated, no? ;)

@jbogard jbogard added this to the 3.3.0 milestone Jul 8, 2014

@jbogard jbogard added the Improvement label Jul 8, 2014


TylerCarlson1 commented Jul 8, 2014

This is the price you pay to use Entity Framework and it's "POCO" classes.
To make things easier for everyone you make it harder on yourself.

@jbogard jbogard closed this in 5cd20e1 Sep 12, 2014

@TylerCarlson1 TylerCarlson1 deleted the TylerCarlson1:InheritanceIssue branch Nov 7, 2015

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