-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider supporting Automapper dependency injection #5288
Comments
Or we can consider compatible https://github.com/AutoMapper/AutoMapper.Extensions.Microsoft.DependencyInjection |
I didn't know this feature of the AutoMapper. While ABP has a way to use DI on the mapping, such a support would be good. You can implement and send a PR. |
Reported by customer |
Currently i use DI in Profile, however this issue should be implemented to allow usage of actions and native DI support of AutoMapper. Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<PortalApplicationModule>();
options.Configurators.Add(abpAutoMapperConfigurationContext =>
{
var profile = abpAutoMapperConfigurationContext.ServiceProvider.GetRequiredService<TestAutoMapperProfile>();
abpAutoMapperConfigurationContext.MapperConfiguration.AddProfile(profile);
});
}); Profile: public class TestAutoMapperProfile : Profile, ITransientDependency
{
public TestAutoMapperProfile() { }
public TestAutoMapperProfile(ITranslatableObjectManager translatableObjectManager)
{
CreateMap<TestGroup, TestGroupListOutputDto>()
.BeforeMap((s, d) =>
{
translatableObjectManager.Translate<TestGroup, TestGroupTranslation>(s);
});
}
} |
Currently, we create Automapper when the application is initialized, But this way we cannot use Automapper's dependency injection function, like: https://docs.automapper.org/en/stable/Before-and-after-map-actions.html#asp-net-core-and-automapper-extensions-microsoft-dependencyinjection
abp/framework/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperModule.cs
Line 30 in a130e0d
We can consider creating Automapper in advance to get dependency injection. example:
The text was updated successfully, but these errors were encountered: