我正在使用Factura和Cfd表,这些表有一对一的关系,但它不起作用。
Cia class
public class clsCiaModel
{
public virtual string Cve_cia { get; set; }
public virtual string Nom_cia { get; set; }
public virtual clsDireccion Direccion { get; set; }
public virtual string Rfc_cia { get; set; }
}
Planta类
public class clsPlantaModel
{
public virtual clsCiaModel Cia_pla { get; set; }
public virtual string Cve_pla { get; set; }
public virtual string Nom_pla { get; set; }
public virtual clsDireccion Direccion { get; set; }
public virtual string Tel1_pla { get; set; }
public virtual long Fnvta_pla { get; set; }
}
基础课程
public abstract class clsaBase
{
public virtual clsPlantaModel Planta { get; set; }
}
Factura课程
public class clsFacturaModel : clsaBase
{
public virtual string Tfac_fac { get; set; }
public virtual int Fol_fac { get; set; }
public virtual string Ser_fac { get; set; }
public virtual DateTime? Fec_fac { get; set; }
public virtual clsClienteModel Numcte_fac { get; set; }
public virtual string Tpa_fac { get; set; }
public virtual string Edo_fac { get; set; }
public virtual string Impr_fac { get; set; }
public virtual clsCfdModel Cfd { get; set; }
}
Cfd class
public class clsCfdModel : clsaBase
{
public virtual clsFacturaModel Fol_cfd { get; set; }
public virtual string Nom_cfd { get; set; }
public virtual DateTime? Fec_cfd { get; set; }
public virtual string Usr_cfd { get; set; }
public virtual string Est_cfd { get; set; }
public virtual string Rfc_cfd { get; set; }
}
Cia制图类
public clsCiaMap()
{
Table("cia");
Id(c => c.Cve_cia, "cve_cia");
Map(c => c.Nom_cia, "nom_cia").Length(40);
Map(c => c.Rfc_cia, "rfc_cia").Length(15).Nullable();
Component(c => c.Direccion,
d =>
{
d.Map(dir => dir.Dir, "dir_cia").Length(40).Nullable();
d.Map(dir => dir.Col, "col_cia").Length(40).Nullable();
d.Map(dir => dir.Ciu, "ciu_cia").Length(40).Nullable();
});
}
Planta制图类
public class clsPlantaMap : ClassMap<clsPlantaModel>
{
public clsPlantaMap()
{
Table("planta");
CompositeId()
.KeyProperty(p => p.Cve_pla, "cve_pla")
.KeyReference(p => p.Cia_pla, "cia_pla");
Map(p => p.Nom_pla, "nom_pla").Length(40).Nullable();
Map(p => p.Tel1_pla, "tel1_pla").Length(30).Nullable();
Map(p => p.Fnvta_pla, "fnvta_pla");
Component(c => c.Direccion,
d =>
{
d.Map(dir => dir.Dir, "dir_pla").Length(40).Nullable();
d.Map(dir => dir.Col, "col_pla").Length(40).Nullable();
d.Map(dir => dir.Ciu, "ciu_pla").Length(30).Nullable();
});
}
}
Factura制图班
public class clsFacturaMap : ClassMap<clsFacturaModel>
{
public clsFacturaMap()
{
Table("factura");
CompositeId()
.KeyProperty(f => f.Fol_fac, "fol_fac")
.KeyProperty(f => f.Ser_fac, "ser_fac")
.KeyReference(f => f.Planta, "pla_fac", "cia_fac");
Map(f => f.Edo_fac, "edo_fac").Length(1).Nullable();
Map(f => f.Fec_fac, "fec_fac").Nullable();
Map(f => f.Impr_fac, "impr_fac").Nullable();
References<clsClienteModel>(f => f.Numcte_fac, "numcte_fac").Nullable().Not.LazyLoad();
Map(f => f.Tfac_fac, "tfac_fac").Length(1);
HasOne<clsCfdModel>(f => f.Cfd).Not.LazyLoad().Cascade.All();
}
}
Cfd制图类
public class clsCfdMap : ClassMap<clsCfdModel>
{
public clsCfdMap()
{
Table("cfd");
CompositeId()
.KeyReference(c => c.Fol_cfd, "fol_cfd", "ser_cfd", "pla_cfd", "cia_cfd");
Map(c => c.Est_cfd, "est_cfd").Length(1).Nullable();
Map(c => c.Fec_cfd, "fec_cfd").Nullable();
Map(c => c.Nom_cfd, "nom_cfd").Length(30).Nullable();
Map(c => c.Rfc_cfd, "rfc_cfd").Length(13).Nullable();
Map(c => c.Usr_cfd, "usr_cfd").Length(8).Nullable();
}
}
当我插入或更新它完美地工作两个表存储数据,但当我查询factura表我得到te错误“索引超出数组的范围”。生成的sql是:
could not load an entity:
[GEN.ETY.clsFacturaModel#component[Fol_fac,Ser_fac,Planta] {
'Fol_fac'='100','Ser_fac'='XXX', 'Planta'='GEN.ETY.clsPlantaModel'}][SQL:
SELECT clsfactura0_.fol_fac as fol1_9_1_, clsfactura0_.ser_fac as ser2_9_1_,
clsfactura0_.pla_fac as pla3_9_1_, clsfactura0_.cia_fac as cia4_9_1_,
clsfactura0_.edo_fac as edo9_9_1_, clsfactura0_.fec_fac as fec11_9_1_,
clsfactura0_.impr_fac as impr18_9_1_, clsfactura0_.tfac_fac as
fac25_9_1_,clsfactura0_.numcte_fac as numcte29_9_1_, clscfdmode1_.fol_cfd as
fol1_0_0_, clscfdmode1_.ser_cfd as ser2_0_0_, clscfdmode1_.pla_cfd as
pla3_0_0_, clscfdmode1_.cia_cfd as cia4_0_0_, clscfdmode1_.est_cfd as
est5_0_0_, clscfdmode1_.fec_cfd as fec6_0_0_, clscfdmode1_.nom_cfd as
nom7_0_0_, clscfdmode1_.rfc_cfd as rfc8_0_0_, clscfdmode1_.usr_cfd as
usr9_0_0_
FROM factura clsfactura0_, outer cfd clscfdmode1_
WHERE clsfactura0_.fol_fac=clscfdmode1_.fol_cfd and
clsfactura0_.ser_fac=clscfdmode1_.ser_cfd and
clsfactura0_.pla_fac=clscfdmode1_.pla_cfd and
clsfactura0_.cia_fac=clscfdmode1_.cia_cfd AND clsfactura0_.fol_fac=? and
clsfactura0_.ser_fac=? and clsfactura0_.pla_fac=? and
clsfactura0_.cia_fac=?]
这个sql在informix上正确运行,我从两个表中获取数据,我不知道出了什么问题?