我有以下实体:
public DbSet<WFPP> WFPPs { get; set; }
....
[Table("PlanningUnit")]
public class PlanningUnit
{
public PlanningUnit()
{
}
public int PlanningUnitId { get; set; }
public Region Region { get; set; }
}
[Table("WFPP")]
public class WFPP
{
public WFPP()
{
AgencyList = new List<PlanningUnit>();
}
public int Id { get; set; }
public List<PlanningUnit> AgencyList;
}
我尝试按如下方式加载实体:
var test= _context.WFPPs.Where(x => x.Id==0).Include(x => x.AgencyList).ToList();
我收到以下错误:
The expression '[x].AgencyList' passed to the Include operator could not be bound.
我无法弄清楚导致此错误的原因,我似乎无法在网上找到太多信息。感谢。
答案 0 :(得分:4)
I tested with console app you just need to add get and set.
[Table("WFPP")]
public class WFPP
{
public WFPP()
{
AgencyList = new List<PlanningUnit>();
}
public int Id { get; set; }
/// your are missing get and set
public ICollection<PlanningUnit> AgencyList { get; set; }
}