简体   繁体   English

实体框架Mysql嵌套属性

[英]Entity Framework Mysql Nested Property

i have this class structure. 我有这个类的结构。 When i do some select i get an exception error. 当我做一些选择时,出现异常错误。

public class A
{
    public int AId { get; set; }
    public virtual ICollection<B> B { get; set; }
}

public class B
{
    public int BId { get; set; }
    public virtual C C { get; set; }

    public int AId { get; set; }
    public virtual A A { get; set; }
}

public class C // Manifiesto carga
{
    [Key]
    [ForeignKey("B")]
    public int CId { get; set; }

    public virtual B B { get; set; }
    public virtual ICollection<D> D { get; set; }
    public virtual ICollection<E> E { get; set; }
}

public class D
{
    public int DId { get; set; }
    public string Nombre { get; set; }

    public int CId { get; set; }
    public virtual C C { get; set; }
}

public class E
{
    public int EId { get; set; }
    public string Nombre { get; set; }

    public int CId { get; set; }
    public virtual C C { get; set; }
}


    context.AA
                .Include(e => e.B.Select(s => s.C.D))
                .Include(e => e.B.Select(s => s.C.E)).FirstOrDefault(e => e.AId == 1);

Im lost, what can i do? 我迷路了,我该怎么办? or where im failing? 还是我失败了?

Thank you. 谢谢。

(sorry for my english) (对不起我的英语不好)

Image exception 图片异常

In the picture above you can see the exception message. 在上图中,您可以看到异常消息。

Is the problem fixed when you also put the parent in D and E 将父级也放在DE时,问题是否解决了?

public class D {
   public virtual C C {get;set;}
}
public class E {
   public virtual C C {get;set;}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM