Greetings,
I'm having a hard time and I can not solve it.
I have an application where I created the mapping and everything was working perfectly, but now I need to change it and that's where the problem comes up:
I used NHibernate Fluent for ORM.
I need to create the mapping using a composite key, that is, in SQL language it would look something like this:
select
*
from
t1
inner join
t2
on t1.codigo = t2.codigo
and t1.versao = t2.versao;
And I can not map the "and" of the join.
My mapping looks like this:
public class T1Map : ClassMap<T1>{
public T2Map() {
Table("TB_WF_T1");
Id(x => x.Codigo, "CD_T1").GeneratedBy.Sequence("SEQ_TB_WF_T1");
Map(x => x.Versao, "CD_VERSAO");
HasMany(x => x.T2).KeyColumn("FK_CODIGO_T1").LazyLoad().Inverse().Cascade.SaveUpdate();
}
}
public class T2Map : ClassMap<T2>{
public T2Map() {
Table("TB_WF_T2");
Id(x => x.Codigo, "CD_T2").GeneratedBy.Sequence("SEQ_TB_WF_T2");
Map(x => x.Versao, "CD_VERSAO");
References(x => x.T1).Column("FK_CODIGO_T1").LazyLoad().Cascade.None();
}
}
My question is how do I map both the "CODE" field and the "VERSION" field.
Is there any way to do this mapping?
Any tips that anyone can help me, I will be very grateful.