FluentNhibernate 映射
这是我的实体关系图
http://s3.subirimagenes.com:81/privadas/1605595base.png
场景:这些是我的简化类
public class plaserv
{
public plaserv()
{
plamoviles = new List<plamoviles>();
asistencia = new List<asistencia>();
plaattach = new List<plaattach>();
}
public virtual double id_planilla { get; private set; }
public virtual double id_parte { get; set; }
...
public virtual int id_tservicio { get; set; }
public virtual int id_legacar { get; set; }
...
public virtual personal personal { get; set; }
public virtual IList<plamoviles> plamoviles { get; private set; }
public virtual plaparte plaparte { get; set; }
public virtual IList<asistencia> asistencia { get; private set; }
public virtual IList<plaattach> plaattach { get; private set; }
}
public class plaparte
{
public virtual double id_planilla { get; private set; }
...
}
public class plamoviles
{
public plamoviles()
{
plamoviles_combustible = new List<combustible>();
plamoviles_moviles = new List<movil>();
}
public virtual double id { get; private set; }
public virtual double id_planilla { get; set; }
public virtual int nmovil { get; set; }
public virtual decimal cant_combustible { get; set; }
public virtual int id_tcombustible { get; set; }
public virtual IList<combustible> plamoviles_combustible { get; private set; }
public virtual IList<movil> plamoviles_moviles { get; private set; }
}
public class plaattach
{
public virtual double id { get; set; }
public virtual double id_planilla { get; set; }
public virtual byte[] archivo { get; set; }
}
public class personal
{
public personal()
{
personal_jerarquia = new List<jerarquia>().OrderBy(x => x.posicion).ToList();
}
public virtual double id_legajo { get; set; }
public virtual string nomyape { get; set; }
public virtual int id_jerar { get; set; }
..
public virtual IList<jerarquia> personal_jerarquia { get; private set; }
}
.....
这些是我的映射
public class plaservMap : ClassMap<plaserv>
{
public plaservMap()
{
Table("plaserv");
Id(x => x.id_planilla);
Map(x => x.autor_llamada).Length(50).Not.Nullable();
Map(x => x.tipo_llamada).Length(3).Not.Nullable();
Map(x => x.direccion).Length(100).Not.Nullable();
Map(x => x.hora_aviso).Length(5).Not.Nullable();
Map(x => x.hora_salida).Length(5).Not.Nullable();
Map(x => x.hora_regreso).Length(5);
Map(x => x.fecha);
Map(x => x.fecha_regreso);
Map(x => x.cant_moviles);
Map(x => x.cant_perso);
Map(x => x.id_legacar);
References(x => x.personal); //muchos a uno
HasMany(x => x.plamoviles).Inverse().Cascade.All();
HasMany(x => x.plaattach).Inverse().Cascade.All();
}
}
正确使用
References(x => x.personal)
我应该添加到类personal以关闭personal与plaserv之间的关系? 我应该在个人中添加类似的内容
HasMany(x => x.plaserv).Inverse().Cascade.All();
This is my entity-relationship diagram
http://s3.subirimagenes.com:81/privadas/1605595base.png
Scenario :These are my classes simplified
public class plaserv
{
public plaserv()
{
plamoviles = new List<plamoviles>();
asistencia = new List<asistencia>();
plaattach = new List<plaattach>();
}
public virtual double id_planilla { get; private set; }
public virtual double id_parte { get; set; }
...
public virtual int id_tservicio { get; set; }
public virtual int id_legacar { get; set; }
...
public virtual personal personal { get; set; }
public virtual IList<plamoviles> plamoviles { get; private set; }
public virtual plaparte plaparte { get; set; }
public virtual IList<asistencia> asistencia { get; private set; }
public virtual IList<plaattach> plaattach { get; private set; }
}
public class plaparte
{
public virtual double id_planilla { get; private set; }
...
}
public class plamoviles
{
public plamoviles()
{
plamoviles_combustible = new List<combustible>();
plamoviles_moviles = new List<movil>();
}
public virtual double id { get; private set; }
public virtual double id_planilla { get; set; }
public virtual int nmovil { get; set; }
public virtual decimal cant_combustible { get; set; }
public virtual int id_tcombustible { get; set; }
public virtual IList<combustible> plamoviles_combustible { get; private set; }
public virtual IList<movil> plamoviles_moviles { get; private set; }
}
public class plaattach
{
public virtual double id { get; set; }
public virtual double id_planilla { get; set; }
public virtual byte[] archivo { get; set; }
}
public class personal
{
public personal()
{
personal_jerarquia = new List<jerarquia>().OrderBy(x => x.posicion).ToList();
}
public virtual double id_legajo { get; set; }
public virtual string nomyape { get; set; }
public virtual int id_jerar { get; set; }
..
public virtual IList<jerarquia> personal_jerarquia { get; private set; }
}
.....
These are my mapping
public class plaservMap : ClassMap<plaserv>
{
public plaservMap()
{
Table("plaserv");
Id(x => x.id_planilla);
Map(x => x.autor_llamada).Length(50).Not.Nullable();
Map(x => x.tipo_llamada).Length(3).Not.Nullable();
Map(x => x.direccion).Length(100).Not.Nullable();
Map(x => x.hora_aviso).Length(5).Not.Nullable();
Map(x => x.hora_salida).Length(5).Not.Nullable();
Map(x => x.hora_regreso).Length(5);
Map(x => x.fecha);
Map(x => x.fecha_regreso);
Map(x => x.cant_moviles);
Map(x => x.cant_perso);
Map(x => x.id_legacar);
References(x => x.personal); //muchos a uno
HasMany(x => x.plamoviles).Inverse().Cascade.All();
HasMany(x => x.plaattach).Inverse().Cascade.All();
}
}
It is properly to use
References(x => x.personal)
I should add to the class personal to close the relationship between personal with plaserv?
I should add something like in personal
HasMany(x => x.plaserv).Inverse().Cascade.All();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我决定通过Automap来实现
I have decided to implement through Automap