EFCore Linq ThenInclude Two Foreign Keys To Same Table

前端 未结 1 431
野的像风
野的像风 2020-12-21 15:18

Does anyone see what I am doing wrong?
ProjectActivityTasks has the UnitOfMeasureId and the ProjectActivityTaskTypeId. With the wa

相关标签:
1条回答
  • 2020-12-21 15:25

    You can (and should) repeat the Include(x => x.ProjectActivityTasks) part:

    var qry = await _projectActivityRepository.GetAll()
    .Include(x => x.ProjectActivityVehicles)
      .ThenInclude(x => x.Vehicle)
    .Include(x => x.ProjectActivityTasks)
      .ThenInclude(x => x.ProjectActivityTaskType)
    .Include(x => x.ProjectActivityTasks)
      .ThenInclude(x => x.UnitOfMeasure)
    .Where(x => x.Id == Id && x.TenantId == (int)AbpSession.TenantId)
    .FirstOrDefaultAsync();
    
    0 讨论(0)
提交回复
热议问题