Base solution for your next web application

Activities of "ymboda"

Question

Hello !

Maybe there is something i misunderstood, but I can't automap my input dto with a multilingual entity. I'm using ASP NET Zero 5.4.1 startup template with ABP 3.2.0 update & .NET Core 2.1.

At the line :

var documentCategory = ObjectMapper.Map<DocumentCategory>(input);

of the method

private async Task Create(CreateOrEditDocumentCategoryDto input)

I get this exception :

_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

CreateOrEditDocumentCategoryDto -> DocumentCategory (Destination member list) Colnec.Documents.Dtos.CreateOrEditDocumentCategoryDto -> Colnec.Documents.DocumentCategory (Destination member list)

Unmapped properties: Translations_

What I'm trying is to convert the name from the dto (simple string) into the entity translations collection (with the default language). The exception seems normal because the map is configure with the dto as the destination, but before creating my own CreateMultiLingualMap function for handle the automatic mapping in this way, is there something I'm missing there ? I followed the documentation from ABP website.

Thank's a lot :)

[Table("DocumentCategories")]
    public class DocumentCategory : FullAuditedEntity<Guid> , IMayHaveTenant, IMultiLingualEntity<DocumentCategoryTranslation>
    {
		public int? TenantId { get; set; }

		[Required]
		[StringLength(DocumentCategoryConsts.MaxLoincCodeLength, MinimumLength = DocumentCategoryConsts.MinLoincCodeLength)]
		public string LoincCode { get; set; }
        public ICollection<DocumentCategoryTranslation> Translations { get; set; }
    }
public class DocumentCategoryTranslation : Entity, IEntityTranslation<DocumentCategory, Guid>
    {
        public string Name { get; set; }
        public DocumentCategory Core { get; set; }
        public Guid CoreId { get; set; }
        public string Language { get; set; }
    }
[AbpAuthorize(AppPermissions.Pages_DocumentCategories_Create)]
        private async Task Create(CreateOrEditDocumentCategoryDto input)
        {
            var documentCategory = ObjectMapper.Map<DocumentCategory>(input);

            if (AbpSession.TenantId != null)
            {
                documentCategory.TenantId = (int?)AbpSession.TenantId;
            }

            await _documentCategoryRepository.InsertAsync(documentCategory);
        }
public class CreateOrEditDocumentCategoryDto : FullAuditedEntityDto<Guid?>
    {
		[Required]
		[StringLength(DocumentCategoryConsts.MaxLoincCodeLength, MinimumLength = DocumentCategoryConsts.MinLoincCodeLength)]
		public string LoincCode { get; set; }
		public string Name { get; set; }
        public int? TenantId { get; set; }
    }
public static void CreateMappings(IMapperConfigurationExpression configuration, MultiLingualMapContext context)
        {
            configuration.CreateMultiLingualMap<DocumentCategory, Guid, DocumentCategoryTranslation, CreateOrEditDocumentCategoryDto>(context);

...
Showing 1 to 1 of 1 entries