simmotech wrote:
But changing the type string does change the type of object (for TargetPerEntityHierarchy not TargetPerEntity). Not any already in-memory entity of course but the next fetch would create an entity of the new type.
That was my observation: the in-memory object type.
simmotech wrote:
I suppose my question was more about how the additional fields (the 4 additional ones shown on the attached image - only relevant for Book & inheritors) are treated if they have non-null values but the object is no longer a Book - are they just ignored?
My guess is that those values stay in the database and are effectively ignored if the entity type is non-Book. But if it got change back to Book again then their values would be seen again.
I didn't try it before, but my guess is that too. However I think this is not guaranteed that works neither between version updates.
Changing the entity type at runtime (in-memory) isn't supported: if you need it, you shouldn't use inheritance. Also, inheritance in entity models is a result of 'interpreting' the data in the db. So manipulating it at runtime could lead to invalid data with respect to inheritance.
So, if you test this and need to use it, then lets go, however I think IMHO that the original problem (invalid data in DB) should be fixed in that arena (using transformation services, migration tools, sanity data checks, triggers, SPs, etc), not in the model and data access layer.