/// <summary> /// This sets all the AutoMapper mapping that this dto needs. It is called from the base constructor /// It also makes sure that any associated dto mappings are set up as the order of creation is not fixed /// </summary> private void MapperSetup() { CreateReadFromDatabaseMapping(); CreatWriteToDatabaseMapping(); //now set up NeedsDecompile any associated mappings. See comments on AssociatedDtoMapping for why these are needed NeedsDecompile = ForceNeedDecompile || CheckComputed.ClassNeedsDecompile(typeof(TEntity)); NeedsDecompile |= SetupAllAssociatedMappings(); }
//--------------------------------------------------------------------- //private methods /// <summary> /// This sets all the AutoMapper mapping that this dto needs. It is called from the base constructor /// It also makes sure that any associated dto mappings are set up as the order of creation is not fixed /// </summary> private void MapperSetup() { var needsDecompile = false; GenericServicesConfig.AutoMapperConfigs.GetOrAdd(CreateDictionaryKey <TEntity, TDto>(), config => new MapperConfiguration(cfg => CreateReadFromDatabaseMapping(cfg, ref needsDecompile))); //now set up NeedsDecompile any associated mappings. See comments on AssociatedDtoMapping for why these are needed NeedsDecompile = ForceNeedDecompile || CheckComputed.ClassNeedsDecompile(typeof(TEntity)); NeedsDecompile |= needsDecompile; if (SupportedFunctions.HasFlag(CrudFunctions.Update) | SupportedFunctions.HasFlag(CrudFunctions.Create)) { //Only setup TDto->TEntity mapping if needed GenericServicesConfig.AutoMapperConfigs.GetOrAdd(CreateDictionaryKey <TDto, TEntity>(), config => new MapperConfiguration(CreateWriteToDatabaseMapping)); } }