Note that there are some explanatory texts on larger screens.

plurals
  1. POc# inheritance trickery with a hierachy
    primarykey
    data
    text
    <p>I have a hiearchy of organizations. Basically, they all share a common base and then each class will declare a name and id. Every derived class will pick up the previous name and id. </p> <p>I need the derived class to be able to show the inherited class's Name property. I'm trying to use base.Name in the get accessor.. Doesnt seem to work.</p> <p>I'm using NHibernate so the properties have to be virtual.. This may be a problem. </p> <p>I have tried to "hide" the Name property by using "new" but then I think base.Name is the new version.</p> <p>The hiearchy looks like this...</p> <pre><code> public class Base { public virtual string Name {get;set;} public virtual string Website {get;set;} } public class Jurisdiction : Base { public virtual string JurisdictionId {get;set;} } public class Conference : Jurisdiction { public virtual string JurisdictionName {get{ return base.Name; }} public virtual string ConferenceId {get;set;} } public class District : Conference { public virtual string ConferenceName {get {return base.Name; }} public virtual string DistrictId {get;set;} } </code></pre> <p>I need.. </p> <ul> <li>District.ConferenceName to return Conference.Name</li> <li>Conference.JurisdictionName to return Jurisdiction.Name</li> </ul> <p>I have googled and stackoverflowed and cannot find the answers.. Thanks for the help</p> <p>EDIT for clarity:</p> <p>I need the classes to to look like this.</p> <ul> <li>District -> Name, DistrictId, ConferenceId, ConferenceName, JurisdictionId, JurisidictionName</li> <li>Conference -> Name, ConferenceId, JurisdictionId, JurisdictionName</li> <li>Jurisdiction -> Name, JurisdictionId</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload