FluentNhibernate 映射

发布于 2024-12-03 09:58:16 字数 3317 浏览 0 评论 0原文

这是我的实体关系图

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满意归宿 2024-12-10 09:58:16

我决定通过Automap来实现

I have decided to implement through Automap

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文