jd wrote:
Hello all. I'm trying to develop a generic database structure using the new target-per-hierarchy stuff, and I have some questions.
Situation:
Let's assume I have 2 tables: Container and Metadata, where metadata is the target-per-hierarchy table. I've declared the associated MetadataEntity abstract, and using a discriminator, have created two subtypes. ContainerType, and ContainerStatus.
I then have 2 foreign keys in the Container table that link to the Metadata table. 1 for the type, and 1 for the status. The problem is that when I create this relationship, the ContainerType and ContainerStatus properties are of type Metadata. Is there a way to make these the appropriate subtypes?
No, because the relation is with MetaData and metadata can be any type in its hierarchy. Though when you traverse / utilize that relation, the object returned will be of a subtype of MetaData, so you have to cast / use is/as, or you can read the discriminator field and base your logic on that to which type to cast the returned object. Because:
Container.MetaData has to have a type, even though MetaData can be a lot of types.
If not, any other suggestions.
What if i want m:n relationships to a subtyped object. So assume that I now have a table called Metadata_Join. The Metadata_Join entity is abstract, and I have subtyped it as well. ContainerSolution and ContainerService. I would like to have 2 collections off of the Collateral table. CollateralSolutionCollection, and CollateralServiceCollection. I'd like for these types to also be typed correctly.
Is this doable? Is there a better way to handle this than the path I'm heading down?
Thanks all.
If I understand it correctly, this should be possible. However you should define relations between Container and ContainerSolution, and between Solution and ContainerSolution to form the m:n relation, IF you want it typed. Otherwise it's polymorphic.