Use this tag for version specific questions about AutoMapper 4 - the convention-based object-to-object mapper and transformer library for .NET. When using this tag also include the more generic [automapper] tag where possible.
Questions tagged [automapper-4]
65 questions
14
votes
2 answers
Using AutoMapper to merge objects
I'm attempting to use AutoMapper to merge data from multiple objects, and I'm running into a couple issues that I can't seem to solve.
I have an object like:
public class Parent
{
public string Id { get; set; }
public List Children {…

kingofzeal
- 1,359
- 3
- 12
- 24
9
votes
1 answer
Automapper 4.2.1 LINQ projections work only with static Mapper.CreateMap?
I'm trying to use Automapper projections on Entity Framework IQueryables.
On application start, I create and add all my mapping profiles which create maps with the non-static CreateMap method.
All those profiles are registered within my IoC…
user5326354
7
votes
1 answer
How to stop Automapper from mapping to parent class when child class was requested
I am working on implementing AutoMapper in our service and am seeing a very confusing issue in our unit tests.
First off this issue involves the following objects and their respective maps:
public class DbAccount : ActiveRecordBase
{
…
user1618236
5
votes
0 answers
Automapper exception handling while mapping list
I have two lists, SRCList and DESTList.
SRCList object has got 6 records.
I am using automapper to map these two list.
While mapping, automapper encounters any problem in mapping the 4th record out of 6, I get AutoMapperMappingException.
Can I skip…

MARKAND Bhatt
- 2,428
- 10
- 47
- 80
5
votes
1 answer
AutoMapper 4.2 not ignoring properties in profile
In my Web API controller method, before I map the UpdatePlaceDTO to PlaceMaster, I make a database call to populate the properties that are not covered by the Map but for some reason AutoMapper makes those properties null.
var mappedPlaceMaster =…

Raihan Iqbal
- 407
- 3
- 16
5
votes
1 answer
AutoMapper: How do I get the name of the destination property
How do I get the name of the destination property:
Public class Source{
public string FirstName{ get; set; }
}
public class Destination{
public string C_First_Name{ get; set; }
}
Using AutoMapper, how do i get the name of the destination…

Lynel Fernandes
- 51
- 1
- 4
5
votes
1 answer
How can I configure Automapper 4 to allow a null destination value
I'm having some problems working out how to get Automapper 4.2.1 to allow for a type mapping where the destination value might be null depending on the source value.
Older versions of Automapper allowed an AllowNullDestination flag to be set via…

NeilMacMullen
- 3,339
- 2
- 20
- 22
4
votes
1 answer
How to Initialize AutoMapper Profiles in referenced project DLLs in ASP.Net webapp
Struggling a little on how to use automapper in my project class libraries (dlls). See my structure of my overall solution below.
The WebApp fires up, and in Global.asax App Start, the AutoMapper.Configure() method is called to add the mapping…

crichavin
- 4,672
- 10
- 50
- 95
4
votes
1 answer
How to map to internal properties using Automapper?
we've been using Automapper for sometime and we think it is great utility, thanks for creating it!
However, we have a question:
Question
"How do you configure AutoMapper to map a source property to an internal destination property?"
Background
In…

Kabua
- 889
- 8
- 19
4
votes
2 answers
Cannot resolve AutoMapper.IMapper using AutoMapper 4.2 with Autofac
I have tried various permutations of this but my current configuration (as it relates to AutoMapper) is like this:
builder.RegisterAssemblyTypes().AssignableTo(typeof(Profile)).As();
builder.Register(c => new MapperConfiguration(cfg =>
{
…

Eonasdan
- 7,563
- 8
- 55
- 82
4
votes
1 answer
Dto with nested Dtos of the same type fails
I faced a problem in a project and have successfully repro'd it in a bare test project.
I have the following dtos:
public class AppUserDto
{
public int Id { get; set; }
public string Name { get; set; }
}
public class IssueDto
{
public…

mrahhal
- 3,322
- 1
- 22
- 41
3
votes
0 answers
Upgrading Automapper and mapping zero to null based based on an attribute
I'm not very familiar with AutoMapper but am trying to update AutoMapper 4 to AutoMapper 10 (last version to support .Net Framework) on a project, and I have run into a problem: The ResolutionContext changed in the 4-5 upgrade so that it no longer…

jmoreno
- 12,752
- 4
- 60
- 91
3
votes
2 answers
Registering AutoMapper ValueResolvers?
I'm on AutoMapper 4.2 and I cant figure out why I'm getting this error
Autofac.Core.Registration.ComponentNotRegisteredException The
requested service
'Navigator.ItemManagement.Data.MappingProfiles.ReportPreferenceReportUserIdsResolver'
has…

Raihan Iqbal
- 407
- 3
- 16
3
votes
1 answer
Automapper - Inheritance mapper not working with Construct
Just yestarday I posted this:
Automapper - Inheritance mapper not working with type converter
Now I'm trying to do what @jimmy-bogard said in his answer, but unfortunately still with no success. Base members don't get mapped.
Jimmy said:
However,…

gabaros
- 743
- 1
- 6
- 24
3
votes
0 answers
Where is GetAllTypeMaps and AutoMapper.Impl.PropertyAccessor in version 4?
Trying to upgrade from 3.2 to 4.2 automapper and I need help in figuring where GetAllTypeMaps has been moved, or how to do following. I was grabbing all maps and finding the ones that are of type "Command" and ignoring "DateCreated". Here is the…

epitka
- 17,275
- 20
- 88
- 141