我正在使用Entity框架Core,我有以下模型类。
class A {
[Key]
public string AId { get; set; }
....
public List<A_B> A_Bs { get; set; }
}
class A_B {
[Key]
public String AId { get; set; }
[Key]
public Int16 BId { get; set; }
[ForeignKey("BId")]
public B B { get; set; }
}
class B {
[Key]
public Int16 Id { get; set; }
.... // Other properties of B
}
根据此页面https://docs.efproject.net/en/latest/querying/related-data.html,以下代码应该有效。
context.A
.Include(e => e.A_Bs)
.ThenInclude(x => x.B) // x has the type of List<A_B> instead of A_B
但是,x
的类型为List<A_B>
且不具有B
的属性?