views:

22

answers:

1

Does anyone know how to to get the inheritance code for a specific type (single table inheritance in Linq to sql) ?

When I create a new entity B (which is inherited from A), I would like to write some code in A, that is valid for all objects inherited from A.

However, when you create a new entity B, it's inheritance code is not yet filled in. Is there any method to get the inheritance code based upon the type? I know there is a metaTable property in the Table class, but it's private and the class is sealed.

A: 

finally found it :

int inheritanceCode= (int)DataContext.Mapping.GetMetaType(instance.GetType()).InheritanceCode;

rekna