I would like to use AutoMapper
in a ASP.NET 4.5 Application that currently uses Unity
to resolve dependencies.
My goal is to be able to use the ProjectTo
extension method to make projections of my entities (from the AutoMapper.EF6 NuGet package).
Could you, please, explain how do I boostrap it?
In ASP.NET Core this is done adding the NuGet package:
AutoMapper.Extensions.Microsoft.DependencyInjection
And adding this:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddAutoMapper(typeof(Startup).Assembly);
...
}
But, that's Core. How do it achieve the same in classic ASP.NET with Unity?
Big thanks!
--
You received this message because you are subscribed to the Google Groups "AutoMapper-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public MyController : ApiController
{
private MyContext _context;
public MyController(MyDbContext context)
{
_context = context;
}
[HttpGet]
public Task<SomeDto> Get(int id)
{
_context.Users
.Where(x => x.Id == id)
.ProjectTo<UserDto>()
.FirstOrDefault();
}
}
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-use...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-users+unsubscribe@googlegroups.com.