C# 从ICollection实体框架核心加载ICollection
我有这些模型,它们都是一对多的连续关系 ListaAbastecimento>ReferenceIAABASTECIMENTO>EtiquetaAbastecimentoC# 从ICollection实体框架核心加载ICollection,c#,asp.net-core-2.2,entity-framework-core-2.2,C#,Asp.net Core 2.2,Entity Framework Core 2.2,我有这些模型,它们都是一对多的连续关系 ListaAbastecimento>ReferenceIAABASTECIMENTO>EtiquetaAbastecimento [Table(name: "hListasAbastecimento")] public class ListaAbastecimento { public int Id { get; set; } public int ColaboradorId { get; set; } [ForeignKe
[Table(name: "hListasAbastecimento")]
public class ListaAbastecimento
{
public int Id { get; set; }
public int ColaboradorId { get; set; }
[ForeignKey("ColaboradorId")]
public virtual Colaborador Colaborador { get; set; }
public string UAP { get; set; }
public DateTime DataCriacao { get; set; }
public virtual ICollection<ReferenciaAbastecimento> Referencias { get; set; }
}
[Table(name: "hReferenciasAbastecimento")]
public class ReferenciaAbastecimento
{
public int Id { get; set; }
[MaxLength(15)]
public string Referencia { get; set; }
public int? QtdAbastecimento { get; set; }
public int? QtdCaixas { get; set; }
public int? QtdPecasPorCaixa { get; set; }
public virtual ICollection<EtiquetaAbastecimento> Etiquetas { get; set; }
}
[Table(name: "hEtiquetasAbastecimento")]
public class EtiquetaAbastecimento
{
public int Id { get; set; }
public int? EtiquetaFIFO { get; set; }
public int? Qtd { get; set; }
[MaxLength(20)]
public string Localizacao { get; set; }
public int ReferenciaAbstecimentoId { get; set; }
[ForeignKey("ReferenciaAbstecimentoId")]
public virtual ReferenciaAbastecimento ReferenciaAbastecimento { get; set; }
}
这不起作用使用
然后在实体框架核心本身支持的多对多关系上包含,编译器应该能够处理所提供的代码。但是,Intellisense和Visual Studio中存在/曾经存在一个错误,它没有正确显示您可以使用的属性。(在您的情况下,Etiquetas
)。可以确认,它是在VS2019(16.2.0预览版1.0)版本中修复的
var abastecimentosList = await _context.ListasAbastecimento
.Include(la => la.Referencias)
.ThenInclude(r => r.Etiquetas) // can't find Etiquetas property
.ToListAsync();