public static void SetupMappingForDto(RegisterOneDtoType dtoRegister, MappingProfile readProfile, MappingProfile saveProfile) { //Now build the mapping using the ConfigGenerator in the register dtoRegister.ConfigGenerator.Accessor.AddReadMappingToProfile(readProfile); //Only add a mapping if AutoMapper can be used to update/create the entity if (dtoRegister.EntityInfo.EntityStyle != EntityStyles.DDDStyled && dtoRegister.EntityInfo.EntityStyle != EntityStyles.ReadOnly) { dtoRegister.ConfigGenerator.Accessor.AddSaveMappingToProfile(saveProfile); } }
private void RegisterDtosInAssemblyAndBuildMaps(Assembly assemblyToScan) { Header = $"Scanning {assemblyToScan.GetName().Name}"; var allTypesInAssembly = assemblyToScan.GetTypes(); var allLinkToEntityClasses = allTypesInAssembly .Where(x => x.GetLinkedEntityFromDto(err => AddError(err)) != null); if (!IsValid) { return; } foreach (var dtoType in allLinkToEntityClasses) { var dtoRegister = new RegisterOneDtoType(dtoType, allTypesInAssembly, PublicConfig); if (!dtoRegister.IsValid) { CombineStatuses(dtoRegister); continue; } SetupMappingForDto(dtoRegister, _readProfile, _saveProfile); } }