In my legacy Database I have a situation like this:
TableA (id_A[PK], cod_A)
TableB (id_B[PK], cod_B, id_A[FK])
TableC (id_C[PK], cod_C, id_B[FK])
For several reasons I need to map these tables into a single class (Foo in this example)
public class Foo
{
public virtual string IdA { get; set; }
public virtual string CodA { get; set; }
public virtual string IdB { get; set; }
public virtual string CodB { get; set; }
public virtual string IdC { get; set; }
public virtual string CodC { get; set; }
}
By the following mapping I'm able to join Table1 and Table2 but not Table3
<class name="Foo" table="TableA">
<id name="IdA" column="id_A"/>
<property name="CodA" column="cod_A"/>
<join table="TableB">
<key column="id_A"/>
<property name="IdB" column="id_B"/>
<property name="CodB" column="cod_B"/>
</join>
<!--Here my problem because off course the join will be on TableA instead on TableB-->
<join table="TableC">
<key column="id_B"/>
<property name="IdC" column="id_C"/>
<property name="CodC" column="cod_C"/>
</join>
</class>
How can I map Table3?
Thanks in advance.