TPC can be strange

Imagine the following tables:


  • Table1
    • Column1 Type1 (PK)
    • Column2 Type2
  • Table2
    • Column1 Type1 (PK)
    • Column2 Type2
    • Column3 Type3

Now, imagine that we want to do the following mapping scenario:


  • EntityType1
    • Prop1
    • Prop2
  • EntityType2 : EntityType1
    • Prop3

To do this, we make TPC to map EntityType2 on Table2.


Then context.EntityTypes1 generates a LEFT OUTER JOIN SQL request.


Now what about context.EntityTypes1.OfType<EntityType2>()?


In this case, as all the EntityType2 properties are mapped on Table2 columns, the query is only on Table2 without including INNER JOIN with Table1.


So what is the problem?


The problem is if you have some records in Table2 without associated record in Table1 (I mean with the same keys). Indeed, in this case, context.EntityTypes1.OfType<EntityType2>() will return them and context.EntityTypes1 won’t.

This entry was posted in 7671, 7674, 7675. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>