I want to retrieve data from the database by linking two tables using asp. boilerplate

Viewed 18

I want to retrieve data from the database by linking two tables using asp. boilerplate. I am using include for gatting match data from the child table. but my mapping of the model also shows the data model not the name of a particular field.

I want to get data from the city table only city name data is retrieved but not mapped Any body?

My Code:

 public async Task<ListResultDto<FirmListDto>> GetAllFirm(GetAllFirmInput input)
    {
        var firmList = await _firmRepository
            .GetAll()
            .Include(t => t.CityName)
            .OrderByDescending(t => t.CreationTime)
            .ToListAsync();

        var checkFirm = new ListResultDto<FirmListDto>(ObjectMapper.Map<List<FirmListDto>>(firmList));

        foreach (var items in checkFirm.Items)
        {
            var getCityName = firmList.FirstOrDefault(p => p.CityId == items.CityId);
            if (items.CityName == null)
                items.CityName = "Null / Empty";
            else
                items.CityName = getCityName.CityName.CityName;
        }

        return checkFirm;
    }
0 Answers
Related