AutoMapper.Extensions.Microsoft.DependencyInjection 12.0.1
AutoMapper extensions for Microsoft.Extensions.DependencyInjection
Scans assemblies and:
- adds profiles to mapping configuration
- adds value resolvers, member value resolvers, type converters to the container.
To use, with an IServiceCollection instance and one or more assemblies:
services.AddAutoMapper(assembly1, assembly2 /*, ...*/);
or marker types:
services.AddAutoMapper(type1, type2 /*, ...*/);
This registers AutoMapper:
- As a singleton for the
MapperConfiguration - As a transient instance for
IMapper ITypeConverterinstances as transientIValueConverterinstances as transientIValueResolverinstances as transientIMemberValueResolverinstances as transientIMappingActioninstances as transient
Mapping configuration is static as it is the root object that can create an IMapper.
Mapper instances are registered as transient. You can configure this with the serviceLifetime parameter. Be careful changing this, as Mapper takes a dependency on a factory method to instantiate the other extensions.
Mapper.Map usage
To map at runtime, add a dependency on IMapper:
public class EmployeesController {
private readonly IMapper _mapper;
public EmployeesController(IMapper mapper)
=> _mapper = mapper;
// use _mapper.Map to map
}
ProjectTo usage
Starting with 8.0 you can use IMapper.ProjectTo. The old ProjectTo is an extension method and does not have dependency injection available. Pass an IConfigurationProvider instance directly:
var orders = await dbContext.Orders
.ProjectTo<OrderDto>(_configurationProvider)
.ToListAsync();
Or you can use an IMapper instance:
var orders = await dbContext.Orders
.ProjectTo<OrderDto>(_mapper.ConfigurationProvider)
.ToListAsync();
Showing the top 20 packages that depend on AutoMapper.Extensions.Microsoft.DependencyInjection.
| Packages | Downloads |
|---|---|
|
Finsa.CaravanCore
Package Description
|
63 |
|
Finsa.CaravanCore
Package Description
|
72 |
|
Finsa.CaravanCore
Package Description
|
73 |
|
Finsa.CaravanCore
Package Description
|
80 |
|
Finsa.CaravanCore
Package Description
|
94 |
|
Finsa.CaravanCore
Package Description
|
105 |
|
Finsa.CaravanCore
Package Description
|
108 |
|
Finsa.CaravanCore
Package Description
|
112 |
|
Finsa.CaravanCore
Package Description
|
114 |
|
Finsa.CaravanCore
Package Description
|
160 |
|
Finsa.CaravanCore
Package Description
|
185 |
|
Finsa.CaravanCore
Package Description
|
213 |
|
Finsa.CaravanCore
Package Description
|
297 |
|
Finsa.CaravanCore
Package Description
|
391 |
|
Finsa.CaravanCore
Package Description
|
441 |
|
Finsa.CaravanCore
Package Description
|
480 |
|
Finsa.CaravanCore
Package Description
|
580 |
|
Finsa.CaravanCore
Package Description
|
1,267 |
|
Finsa.CaravanCore
Package Description
|
2,171 |
.NET Standard 2.1
- AutoMapper (= 12.0.1)
- Microsoft.Extensions.Options (>= 6.0.0)
| Version | Downloads | Last updated |
|---|---|---|
| 12.0.1 | 39 | 12/06/2023 |
| 12.0.0 | 26 | 12/22/2022 |
| 11.0.0 | 267 | 02/18/2022 |
| 8.1.1 | 574 | 02/05/2021 |
| 8.1.0 | 428 | 10/21/2020 |
| 8.0.1 | 41 | 08/25/2020 |
| 8.0.0 | 26 | 02/13/2024 |
| 7.0.0 | 100 | 02/10/2020 |
| 6.1.1 | 31 | 02/11/2020 |
| 6.1.0 | 27 | 02/13/2024 |
| 6.0.0 | 32 | 02/13/2024 |
| 5.0.1 | 26 | 02/13/2024 |
| 4.0.1 | 29 | 01/26/2024 |
| 3.2.0 | 29 | 01/30/2024 |
| 3.1.0 | 30 | 01/18/2024 |
| 3.0.1 | 27 | 02/13/2024 |
| 2.0.1 | 26 | 02/13/2024 |
| 2.0.0 | 28 | 02/13/2024 |
| 1.2.0 | 28 | 02/13/2024 |
| 1.1.2 | 28 | 02/13/2024 |
| 1.1.0 | 24 | 01/18/2024 |
| 1.0.1-alpha | 24 | 02/13/2024 |
| 1.0.0-alpha | 40 | 01/08/2024 |