Мое приложение Ef core 2.2, отложенная загрузка не включена.
При адресе объекта метода MapAddress объект Country объекта имеет значение null, хотя у меня есть
Включить (a => a. Адрес) .ThenInclude (a => a.Country)
для быстрой загрузки страны.
var agentWalletResponse = (from wd in dbContext.WalletDetail.Where(w => w.WalletDetailId == agentWalletDetailId)
join c in dbContext.CorporateInfo.Include(a => a.Address).ThenInclude(a => a.Country).Where(d => !d.IsDeleted) on wd.WalletSubscriptionId equals c.OwnerUserId
select new AgentWalletResponse()
{
Address = MapAddress(c.Address),
Balance = wd.AvailableBalance,
CreatedOn = wd.CreatedOn
}).FirstOrDefault();
Адрес карты
protected AddressModel MapAddress(Address address)
{
if (address == null)
return null;
return new AddressModel
{
AddressId = address.AddressId,
AddressLine = address.AddressLine1,
City = address.City,
Country = address.Country?.Name,
Province = address.Province,
Division = address.Division,
PhoneNumber = address.PhoneNumber,
PostalCode = address.PostalCode
};
}