I've read about it in the manual... but I seem to be missing its purpose.

Why not just create a different type, instead of using type discriminators?

asked Sep 16 '10 at 06:35

ara's gravatar image


edited Sep 17 '10 at 01:10

Alex%20Yakunin's gravatar image

Alex Yakunin

One Answer:

Type discriminators allow you to use a different column (and, correspondingly, values) to identify entity type associated with a particular row in case when inheritance is used in hierarchy.

You may need this feature in just one case: you have a legacy database, the schema there has such hierarchies, and you want to map our types to it.

So if you don't use legacy database, you don't need this feature. Btw, standard TypeId must work a bit faster (actually, we inject CASE ... into SQL to convert type discriminator column values to our TypeId format in SQL on the fly).

answered Sep 17 '10 at 01:03

Alex%20Yakunin's gravatar image

Alex Yakunin

edited Sep 17 '10 at 01:03

Thanks for the explanation, Alex. Is it also implicitly used when using SingleTable inheritance schema? Otherwise, how would DO know the entity type of each row?

(Sep 17 '10 at 01:37) ara ara's gravatar image

DO adds TypeId column, if there are more then one type in a hierarchy with any kind of inheritance mapping.

I.e. TypeId is default type discriminator.

(Sep 17 '10 at 02:57) Alex Yakunin Alex%20Yakunin's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA