[nhusers] Non-trivial inheritance strategy

4 views
Skip to first unread message

indiansummersky

unread,
May 10, 2010, 11:15:46 AM5/10/10
to nhusers
Hi,

I'm using ActiveRecord and trying to configure an object hierarchy
that utilises table-per-class at the top and single-table-inheritance
deeper in the tree. Upon initializing ActiveRecord, I'm getting the
exception message "The 'discriminator-value' attribute is not
declared."

My class hierarchy is:

[ActiveRecord, JoinedBase]
public abstract class Animal : ActiveRecordBase
{
[PrimaryKey]
public int Id { get; private set; }

[Property]
public int Age { get; set; }

[Property]
public string Name { get; set; }
}

[ActiveRecord]
public class Python : Animal
{
[JoinedKey]
public int AnimalId { get; private set; }

[Property]
public int Length { get; set; }
}

[ActiveRecord]
public class Barracuda : Animal
{
[JoinedKey]
public int AnimalId { get; private set; }

[Property]
public string Colour { get; set; }
}

[ActiveRecord(DiscriminatorColumn = "Type", DiscriminatorType =
"String", DiscriminatorValue="Mammal")]
public abstract class Mammal : Animal
{
[JoinedKey]
public int AnimalId { get; private set; }

[Property]
public int GestationPeriodDays { get; set; }
}

[ActiveRecord(DiscriminatorValue="Elephant")]
public class Elephant : Mammal
{
[Property]
public int TuskLength { get; set; }
}

[ActiveRecord(DiscriminatorValue = "Human")]
public class Human : Mammal
{
[Property]
public string HairColour { get; set; }
}

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.

Reply all
Reply to author
Forward
0 new messages