Base solution for your next web application
Open Closed

Multi-lingual entity - AutoMapper - Unmapped properties: Capacity #7267


User avatar
0
alexanderpilhar created

7.0.0, Angular, .NET Framework

I'm having troubles with one of my multi-lingual entities - see log:

ERROR 2019-07-08 15:55:00,824 [13   ] Mvc.ExceptionHandling.AbpExceptionFilter - 
Unmapped members were found. Review the types and members below.
Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type
For no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters
=====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
AutoMapper created this type map for you, but your types cannot be mapped using the current configuration.
Task`1 -> List`1 (Destination member list)
System.Threading.Tasks.Task`1[[System.Collections.Generic.List`1[[CompanyName.ProjectName.EntityFeatures.EntityFeatureTranslation, CompanyName.ProjectName.Core, Version=6.5.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] -> System.Collections.Generic.List`1[[CompanyName.ProjectName.Backend.EntityFeatures.Dto.EntityFeatureTranslationBackendDto, CompanyName.ProjectName.Application.Shared, Version=6.5.0.0, Culture=neutral, PublicKeyToken=null]] (Destination member list)

Unmapped properties:
Capacity

AutoMapper.AutoMapperConfigurationException: 
Unmapped members were found. Review the types and members below.
Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type
For no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters
=====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
AutoMapper created this type map for you, but your types cannot be mapped using the current configuration.
Task`1 -> List`1 (Destination member list)
System.Threading.Tasks.Task`1[[System.Collections.Generic.List`1[[CompanyName.ProjectName.EntityFeatures.EntityFeatureTranslation, CompanyName.ProjectName.Core, Version=6.5.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] -> System.Collections.Generic.List`1[[CompanyName.ProjectName.Backend.EntityFeatures.Dto.EntityFeatureTranslationBackendDto, CompanyName.ProjectName.Application.Shared, Version=6.5.0.0, Culture=neutral, PublicKeyToken=null]] (Destination member list)

Unmapped properties:
Capacity

   bei AutoMapper.ConfigurationValidator.AssertConfigurationIsValid(IEnumerable`1 typeMaps)
   bei lambda_method(Closure , Task`1 , List`1 , ResolutionContext )
   bei lambda_method(Closure , Object , Object , ResolutionContext )
   bei AutoMapper.Mapper.AutoMapper.IMapper.Map[TDestination](Object source)
   bei CompanyName.ProjectName.Backend.EntityFeatures.EntityFeatureBackendAppService.<GetTranslationsForEntityFeaturePagedAndSortedAsync>d__14.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei lambda_method(Closure , Object )
   bei Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.<Execute>d__0.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   bei Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   bei Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__13.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextExceptionFilterAsync>d__24.MoveNext()

Here are the involved classes:

public class EntityFeature : FullAuditedEntity, IMultiLingualEntity<EntityFeatureTranslation>, IPassivable
{
    [Required]
    [MaxLength(EntityConsts.EntityFeature.MaxLengthLabelCssClasses)]
    public virtual string LabelCssClasses { get; set; }

    [Required]
    [MaxLength(EntityConsts.EntityFeature.MaxLengthIconCssClasses)]
    public virtual string IconCssClasses { get; set; }

    public virtual bool IsActive { get; set; }

    public virtual ICollection<EntityFeatureTranslation> Translations { get; set; }
}
public class EntityFeatureTranslation : AuditedEntity, IEntityTranslation<EntityFeature>
{
    [Required]
    [MaxLength(EntityConsts.EntityFeature.MaxLengthName)]
    public virtual string Name { get; set; }

    [Required]
    [MaxLength(EntityConsts.EntityFeature.MaxLengthTitleHtmlTag)]
    public virtual string TitleHtmlTag { get; set; }

    public virtual EntityFeature Core { get; set; }

    public virtual int CoreId { get; set; }

    [Required]
    [MaxLength(EntityConsts.Translation.MaxLengthLanguage)]
    public virtual string Language { get; set; }
}
public class EntityFeatureBackendDto : FullAuditedEntityDto, IPassivable
{
    public string Name { get; set; }

    public string TitleHtmlTag { get; set; }

    public string LabelCssClasses { get; set; }

    public string IconCssClasses { get; set; }

    public bool IsActive { get; set; }

    public ICollection<EntityFeatureTranslationBackendDto> Translations { get; set; }
}
public class EntityFeatureTranslationBackendDto : AuditedEntityDto
{
    public string Name { get; set; }

    public string TitleHtmlTag { get; set; }

    public string Language { get; set; }
}

There are other multi-lingual entities as well, all of them working as expected. Any ideas what's wrong with this one?


3 Answer(s)
  • User Avatar
    1
    maliming created
    Support Team

    You don't seem to have await on the asynchronous method.

  • User Avatar
    0
    alexanderpilhar created

    You are right @maliming! Didn't see it myself, not even in code (overlooked many times...) - how were you able to tell from log message? Experience? Thanks a lot!

  • User Avatar
    0
    maliming created
    Support Team

    I guessed it through this information.

    Task -> List

    Task`1 -> List`1 (Destination member list)
    
    System.Threading.Tasks.Task`1[[System.Collections.Generic.List`1[[CompanyName.ProjectName.EntityFeatures.EntityFeatureTranslation, CompanyName.ProjectName.Core, Version=6.5.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
    
    -> 
    
    System.Collections.Generic.List`1[[CompanyName.ProjectName.Backend.EntityFeatures.Dto.EntityFeatureTranslationBackendDto, CompanyName.ProjectName.Application.Shared, Version=6.5.0.0, Culture=neutral, PublicKeyToken=null]] (Destination member list)