This project is read-only.

Inheritance question : parent has 1:M relationships

Mar 22, 2010 at 10:10 PM


I hit this problem in my project and recreated it in a new test project.  I have 3 tables in the test project, which I created through nhydrate and fired off at a blank database:

ParentId  <-- PK, identity

Child  <-- Has parent set as "Parent" in the nhydrate.wsgen
ParentId  <-- PK/FK, non-identity

ParentsThings  <-- many to one relationship with Parent
ParentsThingsId  <-- PK
ParentId  <-- FK


Then populated the tables with some data and set up a simple test:


Child foo = Child.SelectUsingPK(1);


The first 3 assertions succeed, so the inheritance appears to be working.  However, the 4th assertion fails because the ParentsThingsList is never getting populated.  To make things worse, once I turned on inheritance, I lost the ability to access the parent table via foo.ParentItem or something similar, so I have no way of getting to the tables that have relationships with the parent.

I'm crossing my fingers that I'm just doing something wrong.  Any ideas?


Mar 23, 2010 at 12:03 AM

To add to what greg said, we also tried

Parent bar = Parent.SelectUsingPK(1);


Which passed. So that parent to parentThingList relationship worked. But the one from the Child to ParentThingList didn't.



Mar 23, 2010 at 3:27 PM

First off there is no ParentItem from a child because it is the parent. They are the same object. You should see all child and parent properties on that object. That said please send your model/sample project to