I'm trying to create a parent entity (Policy) with two child-entity collections (ExpressionRules and ThresholdRules) where the types of the child-entities are the same and exist in the same table. For example:
class Policy
{
ICollection<Rule> ExpressionRules { get; set; }
ICollection<Rule> ThresholdRules { get; set; }
}
class Rule
{
public virtual int SequenceNumber { get; set; }
public virtual ICondition Condition { get; set; }
}
interface ICondition
{
}
class ExpressionCondition : ICondition
{
public virtual string Expression { get; set; }
}
class ThresholdCondition : ICondition
{
public virtual int Threshold { get; set; }
}
In practice each set of rules will have different ICondition implementers inside them. ICondition mappings have discriminators according to which the correct implementation is loaded. But the rules in the two sets are identical and I would like them to be mapped to the same table.
Is this possible?
(If you add mapping examples please use xml-mappings if possible.)