Kevin Versfeld
Kevin Versfeld

Reputation: 720

Entity Framework 4 TPH: Why can't I get the value of the discriminator?

I've seen similar questions asked, but the answers haven't helped me yet. I am modelling TPH in my system (going POCO by the way), for data that is displayed in a Treeview (some sort of collection of the superclass is loaded and displayed). Now I need to do various things (such as UI styling, bizrules etc) based on the type of each object. Comparisons on the Type of the object is inadequate for several reasons (which I won't go into now). What I really need is just a simple representation of that discriminator as a property. It can be read-only (in fact, it should be, for obvious reasons). I get that EF doesn't want to allow you to (effectively) mess with the type of the object, but really? Any thoughts?

Upvotes: 1

Views: 612

Answers (1)

Craig Stuntz
Craig Stuntz

Reputation: 126547

You can't do it. But since the discriminator value and the type are one and the same thing, it's less than clear why you say "Comparisons on the Type of the object is inadequate for several reasons (which I won't go into now)."

Upvotes: 1

Related Questions