NHibernate: discriminator without common base class?

Posted by joniba on Stack Overflow See other posts from Stack Overflow or by joniba
Published on 2012-03-07T18:39:18Z Indexed on 2012/03/20 17:29 UTC
Read the original article Hit count: 228

Is it possible to map two classes to the same property without them sharing a common base class?

For example, a situation like this:

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; }
}

I also cannot add some empty abstract class that both conditions inherit from because the two ICondition implementations exist in different domains that are not allowed to reference each other. (Please no responses telling me that this situation should not occur in the first place - I'm aware of it and it doesn't help me.)

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about nhibernate-mapping