I'm trying to create a Criteria query to select objects that are related via an association table.
Insurer * - 1 Insurer_Section 1 - * Section
InsurerSection has an association attribute: active:bool.
How do I get all Insurers whose active attribute in the InsurerSection class is set to true?
PS: I can't go like this:
Insurer.FindAll( DetachedCriteria.For().CreateCriteria("Insurer_Section").Add(Expression.Eq("Active", true) );
because Insurer_Section is an association table that is only mapped via HasAndBelongsToMany:
[HasAndBelongsToMany(typeof(Section), Table = "Insurer_Section
",
ColumnKey = "IdInsurer
", ColumnRef = "IdSection
",
Cascade = ManyRelationCascadeEnum.AllDeleteOrphan)]
private IList Sections {
get { return this.sections; }
set { this.sections = value; }
}
AND
[HasAndBelongsToMany(typeof(Insurer), Table = "Insurer_Section
",
ColumnKey = "IdSection
", ColumnRef = "IdInsurer
",
Cascade = ManyRelationCascadeEnum.None, Inverse = true)]
public IList Insurers {
get { return this.insurers; }
set { this.insurers = value; }
}