2
有沒有人看到我在做什麼錯了?
ProjectActivityTasks
具有UnitOfMeasureId
和ProjectActivityTaskTypeId
。隨着它的寫法,它認爲UnitOfMeasure
去ProjectActivityTaskType
。它示數出來就ThenInclude
爲UnitOfMeasure
說EFCore Linq Then然後包括兩個外鍵到同一個表
ProjectActivityTaskType不包含定義UnitOfMeasure
這是正確的。 UnitOfMeasure
轉到ProjectActivityTasks
。
我引用此頁面,但它似乎並沒有這樣的工作方式:https://docs.microsoft.com/en-us/ef/core/querying/related-data
var qry = await _projectActivityRepository.GetAll()
.Include(x => x.ProjectActivityVehicles)
.ThenInclude(x => x.Vehicle)
.Include(x => x.ProjectActivityTasks)
.ThenInclude(x => x.ProjectActivityTaskType)
.ThenInclude(x => x.UnitOfMeasure)
.Where(x => x.Id == Id && x.TenantId == (int)AbpSession.TenantId)
.FirstOrDefaultAsync();