Open Closed

Unable to load the Tenants in Saas page. Volo.Saas.Tenants.Tenant -> Volo.Saas.Host.Dtos.SaasTenantDto mapping issue #3794


User avatar
0
Yaduraj created
  • ABP Framework version: 4.3.1
  • UI type: Angular / .Net Core
  • DB provider: EF Core / PostgreSql
  • Exception message and stack trace:

Timestamp - 09/29/2022 06:31:39 +00:00 | Level - Error | Message Error mapping types. Mapping types: Object -> List1 System.Object -> System.Collections.Generic.List`1[[Volo.Saas.Host.Dtos.SaasTenantDto, Volo.Saas.Host.Application.Contracts, Version=4.3.1.0, Culture=neutral, PublicKeyToken=null]] { "SourceContext": { "Value": "Volo.Abp.AspNetCore.Mvc.ExceptionHandling.AbpExceptionFilter" }, "ActionId": { "Value": "72a05745-907d-44f5-a405-7ec0d6cd851a" }, "ActionName": { "Value": "Volo.Saas.Host.TenantController.GetListAsync (Volo.Saas.Host.HttpApi)" }, "RequestId": { "Value": "0HML1D7DDQJB6:00000002" }, "RequestPath": { "Value": "/api/saas/tenants" }, "ConnectionId": { "Value": "0HML1D7DDQJB6" } } Exception - AutoMapper.AutoMapperMappingException: Error mapping types.

Mapping types: Object -> List1 System.Object -> System.Collections.Generic.List1[[Volo.Saas.Host.Dtos.SaasTenantDto, Volo.Saas.Host.Application.Contracts, Version=4.3.1.0, Culture=neutral, PublicKeyToken=null]] ---> AutoMapper.AutoMapperMappingException: Error mapping types.

Mapping types: Tenant -> SaasTenantDto Volo.Saas.Tenants.Tenant -> Volo.Saas.Host.Dtos.SaasTenantDto

Type Map configuration: Tenant -> SaasTenantDto Volo.Saas.Tenants.Tenant -> Volo.Saas.Host.Dtos.SaasTenantDto

Destination Member: ExtraProperties

---> System.ArgumentNullException: Value cannot be null. (Parameter 'sourceDictionary') at Volo.Abp.Check.NotNull[T](T value, String parameterName) at Volo.Abp.ObjectExtending.ExtensibleObjectMapper.MapExtraPropertiesTo(Type sourceType, Type destinationType, Dictionary2 sourceDictionary, Dictionary2 destinationDictionary, Nullable1 definitionChecks, String[] ignoredProperties) at Volo.Abp.ObjectExtending.ExtensibleObjectMapper.MapExtraPropertiesTo[TSource,TDestination](Dictionary2 sourceDictionary, Dictionary2 destinationDictionary, Nullable1 definitionChecks, String[] ignoredProperties) at AutoMapper.AbpAutoMapperExtensibleDtoExtensions.<>c__DisplayClass0_02.&lt;MapExtraProperties&gt;b__3(TSource source, TDestination destination, ExtraPropertyDictionary extraProps) at lambda_method5808(Closure , Object , List1 , ResolutionContext ) --- End of inner exception stack trace --- at lambda_method5808(Closure , Object , List1 , ResolutionContext ) --- End of inner exception stack trace --- at lambda_method5808(Closure , Object , List1 , ResolutionContext ) at Volo.Abp.ObjectMapping.DefaultObjectMapper.Map[TSource,TDestination](TSource source) at Volo.Saas.Host.TenantAppService.GetListAsync(GetTenantsInput input) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope) at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at lambda_method5764(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeActionMethodAsync&gt;g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.

  • Steps to reproduce the issue:" NA

4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please try to add the below AutoMapper config.

    CreateMap<Tenant, SaasTenantDto>()
        .MapExtraProperties()
        .Ignore(t => t.EditionName)
        .ForMember(
            t => t.HasDefaultConnectionString,
            opt =>
            {
                opt.MapFrom(t =>
                    t.FindDefaultConnectionString() != null
                );
            }
        );
    
    CreateMap<Edition, EditionDto>()
        .MapExtraProperties()
        .Ignore(x => x.PlanName);
    
    CreateMap<Edition, EditionLookupDto>()
        .MapExtraProperties();
    
  • User Avatar
    0
    Yaduraj created

    Hi @maliming Thanks for your response please can you provide more details:

    1. EditionDto does not contain PlanName
    2. EditionLookupDto - Please specify the package or library to be included. I don't find it anywhere in https://docs.abp.io/api-docs/commercial/3.3/api/Volo.Saas.Host.Dtos.EditionDto.html

    Screen of our code:

    Also, we are you using AutoMaper instead of Volo.Abp.AutoMapper, can I use both? What is the difference between : Volo.Saas.Tenants and Volo.Saas.Host.Dtos and in which version these are being used.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Also, we are you using AutoMaper instead of Volo.Abp.AutoMapper, can I use both?

    Volo.Abp.AutoMapper will include AutoMaper .

    How about this one? the key is MapExtraProperties.

    CreateMap<Tenant, SaasTenantDto>()
        .MapExtraProperties()
        .Ignore(t => t.EditionName)
        .ForMember(
            t => t.HasDefaultConnectionString,
            opt =>
            {
                opt.MapFrom(t =>
                    t.FindDefaultConnectionString() != null
                );
            }
        );
    

    If not work for you please share the steps to reproduce the problem.

  • User Avatar
    0
    Yaduraj created

    @maliming Thanks for you support. This is was resolved and it was due to data issues and not any technical problem.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11