We have possibly a unique situation we've gotten ourselves into. In our model, we have a base supertype called Component. This is represented by a single physical table.
A given Component entity can have multiple subtypes. The hiearchy is based on propagating the primary key of the supertype table (ComponentId.)
So, for a given (abstract) ComponentId, you could have 1 to N subtype instances. Each subtype lives in its own 'leaf' table (ComponentTypeA, ComponentTypeB, etc.)
This works beautifully doing polymorphic fetches, prefetches, etc. It's been a godsend.
The problem is performing INSERTs. If you have defined 3 subtype instances to be added, to be gathered under one supertype instance, looking something like this:
MySuperType1- PK value=1
--MySubTypeA (PK == 1) + subtype fields
--MySubTypeB (PK==1) + other subtype field
--MySubTypeC (PK ==1) + yet more subtype fields
We can't figure out how to actually save this... If we loop thru the subtype instances, the first entity (subtype and supertype) saves correctly. However, after various different approaches, for each additional subtype entity, we either get PK violations in the supertype table, or we end up with 3 different supertype entities saved.
We could write stored procs or flatten tables, but this would basically require scrapping our project and starting over (since we have several hundred of these tables to support.)
i tried to make this a generic question, but of course i can give nasty specific details if desired (fair warning!)
Thanks much!
(using LLBLGen 2.0, .Net 2.0 libs, assembly ver 2.0.50727, built-in Adapter templates, SQL Server 2005)