Home All Groups Group Topic Archive Search About

Confusing Error related to MappingSource?

Author
26 Oct 2007 8:05 PM
Benjamin
I'm trying to force LINQ to SQL to do some inheritance modeled around the
"Table per Concrete Class" methodology as opposed to the normal "Table per
Class Hierarchy" model it officially supports.  To do this, I omitted all the
properties of the inheritance relationship (Discriminator information and
such) and provided the proper Table attribute to associate my derived class
with its own table by addint a new partial class implementation manually.

So what I end up with is a base class that has all the columns in it, and
two derived classes that inherit from it in the designer, and have no
additional properties.  Then in another file, I declare both derived classes
just to supply the Table attribute, providing each derived class' table name.

The problem I run into is this error message:
"Data member 'Int32 DocNum' of type '(my base class)' is not part of the
mapping for type '(my derived class)'. Is the member above the root of an
inheritance hierarchy?"

Now I've checked the contents of the MappingSource.  I retrieved
context.Mapping.GetMetaType(GetType(<my derived class>)).DataMembers and was
able to verify in the debug window that the DocNum property was defined in
that MetaType information, and the DeclaringType matched <my derived class>,
so I don't know what it's complaining about.  Is there any way to make this
work?  Any explanation what this error is complaining about?  I did notice
that if I create a property in my derived class that shadows the base class
DocNum property, then that property doesn't have the error any more (the next
property does).  But the point is not to have to re-declare all the
properties in all me derived classes again.  Why doesn't it pick up the base
class' attributes, even though the mapping info makes it look like it did?

AddThis Social Bookmark Button