Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "direccionti"

Hello! I have a problem when get all organization units.

My Custom class:

public class OrganizationUnitExtended: OrganizationUnit
    {
        public virtual int TipoUnidadOrganizacionalId { get; set; }

        [ForeignKey("TipoUnidadOrganizacionalId")]
        public virtual TipoUnidadOrganizacional TipoUnidadOrganizacionalFk { get; set; }

        public virtual int MunicipioId { get; set; }

        [ForeignKey("MunicipioId")]
        public virtual Municipio MunicipioFk { get; set; }
    }

Dto: the two fields are in the necessary dto.

public class OrganizationUnitDto : AuditedEntityDto<long>
    {
        public long? ParentId { get; set; }

        public string Code { get; set; }

        public string DisplayName { get; set; }

        public int MemberCount { get; set; }
        
        public int RoleCount { get; set; }

        public int TipoUnidadOrganizacionalId { get; set; }

        public int MunicipioId { get; set; }
    }

DbContext:

public virtual DbSet<OrganizationUnitExtended> OrganizationUnitsExtended { get; set; }

Mapper:

//OrganizationUnit
            configuration.CreateMap<OrganizationUnit, OrganizationUnitDto>();
            configuration.CreateMap<OrganizationUnitExtended, OrganizationUnitDto>().ReverseMap();

Service:

Defintion:

private readonly IRepository<OrganizationUnitExtended, long> _lookup_organizationUnitExtendedRepository;

public CommonLookupAppService(
...
IRepository<OrganizationUnitExtended, long> lookup_organizationUnitExtendedRepository,
...
){
_lookup_organizationUnitExtendedRepository = lookup_organizationUnitExtendedRepository;
....
}

Method: I want to get all organization units for the new field (TipoUnidadOrganizacional)

public async Task<PagedResultDto<OrganizationUnitLookupTableDto>> GetAllOrganizationUnitForLookupTable(GetAllForLookupTableInput input)
        {
            long currentUserId = Convert.ToInt64(AbpSession.UserId);

            var query = (from uou in _userOrganizationUnitRepository.GetAll()
                         join ou in _lookup_organizationUnitExtendedRepository.GetAll() on uou.OrganizationUnitId equals ou.Id
                         where uou.UserId == currentUserId && ou.TipoUnidadOrganizacionalId == (int)eTiposUnidadesOrganizacionales.Vitrina
                         select ou);

            var totalCount = await query.CountAsync();

            var organizationUnitList = await query
                .PageBy(input)
                .ToListAsync();

            var lookupTableDtoList = new List<OrganizationUnitLookupTableDto>();
            foreach (var organizationUnit in organizationUnitList)
            {
                lookupTableDtoList.Add(new OrganizationUnitLookupTableDto
                {
                    Id = organizationUnit.Id,
                    DisplayName = organizationUnit.DisplayName?.ToString()
                });
            }

            return new PagedResultDto<OrganizationUnitLookupTableDto>(
                totalCount,
                lookupTableDtoList
            );
        }

My error:

"Invalid column name 'Discriminator'.\r\nInvalid column name 'Discriminator'."

I need help! thanks!

Showing 11 to 11 of 11 entries