在我的旧数据库中,我遇到了这样的情况:
TableA (id_A[PK], cod_A)
TableB (id_B[PK], cod_B, id_A[FK])
TableC (id_C[PK], cod_C, id_B[FK])
出于多种原因,我需要将这些表映射到一个类中(本例中为 Foo)
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; }
}
通过以下映射,我可以加入 Table1 和 Table2 但不能加入 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>
如何映射 Table3?
提前致谢。