Search code examples
fluent-nhibernatefluent-nhibernate-mapping

Fluent NHibernate - mapping multiple levels of inheritance with multiple discriminators


With the following class hierarchy - what would the DiscriminateSubClassesOnColumn("").Formula([insert custom sql here]) statements look like?

public abstract class Base
{
    public virtual string FEE_IND { get; set; }
    public virtual string REC_PAY { get; set; }
}

//  FEE_IND == "03"
public abstract class Child : Base
{}

//  FEE_IND == "03"
//  REC_PAY == "P"
public class ChildChild : Child
{}

I haven't been able to find anything that I could wrap my head around.


Solution

  • .Formula("Concat(FEE_IND, REC_PAY)")
    
    // Child
    .DiscriminatorValue("03");
    
    // ChildChild 
    .DiscriminatorValue("03P");