Use this tag for version specific questions about AutoMapper 5 - 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-5]
106 questions
5
votes
1 answer
Automapper with resolver throwing "Error mapping types"
We have a class inside another class as a property which needs to be mapped using Automapper. We have written a resolver which will map the source class properties to destinationMember properties. I have written the below logic which is not working.…

Keppy
- 471
- 1
- 7
- 23
4
votes
1 answer
Automapper: Handling Nullable Properties for Object To Object Mapping
I am using Automapper 6.0.2. I have a console application with the following code below. I am trying to achieve a sort or partial update feature by placing a condition for the object to object mapping relationship. So I am using:
.ForAllMembers(opt…

flexxxit
- 2,440
- 5
- 42
- 69
4
votes
1 answer
Automapper Expression Error: Null Reference/Error Mapping Types and ReverseMap
I am trying to use AutoMapper to map between two models in an expression, but receiving an error from AutoMapper: "Error Mapping Types" with an Inner Exception Message of "Object reference not set to an instance of an object."
I set up my…

kay
- 195
- 1
- 5
- 15
4
votes
2 answers
Configure Automapper Profile Class with Parameter Constructor and Ninject
I am using Automapper (v5.1.1.0) and Ninject (v3.2.0.0). My Profile class is:
public class ApplicationUserResponseProfile : Profile
{
public ApplicationUserResponseProfile(HttpRequestMessage httpRequestMessage)
{
UrlHelper urlHelper…

Asraf Uddin Ahmed
- 172
- 1
- 8
4
votes
1 answer
Automapper (5.1.1) ForAllMembers - Get name of the current property
Here is my problem, in Condition I want to get to the name of the current property being evaluated. I believe you could do this in earlier versions of Automapper. Any suggestions?
[TestFixture]
public class SandBox
{
public class MySource
{
…

Pelle
- 2,755
- 7
- 42
- 49
4
votes
1 answer
Difference between IMapper and IMappingEngine in Automapper
I am using IMapper which is configured as follows:
var mapperConfig = new MapperConfiguration(cfg => {
cfg.CreateMap();
cfg.CreateMap();
…

VivekDev
- 20,868
- 27
- 132
- 202
4
votes
1 answer
Mapping from double
Using Automapper 5.0.2.0 I am attempting to map From TypeA to TypeB:
public class TypeA
{
public double Length { get; set; }
}
public class TypeB
{
public Distance Length { get; set; }
}
I make the assumption that the Length is stored in…

jth41
- 3,808
- 9
- 59
- 109
3
votes
1 answer
Conditional Mapping from Parameter in Automapper
I want to pass a paramether to a mapping so then it decides a value based on that parameter.
A simple class
public class Person
{
string Name;
}
And its DTO
public class PersonDTO
{
string Name;
string IsAProgrammer;
}
I want something Like…

evilpixi
- 83
- 8
3
votes
1 answer
AutoMapper 5.2.0 VIewModel to Model issue in Core MVC
Models:
public class Client{
public int Id {get;set;}
public string Name {get;set;}
public Address Address {get;set;}
public int AddressId {get;set;}
}
public class Address{
public int Id
public string Address1…

akd
- 6,538
- 16
- 70
- 112
3
votes
2 answers
Configuring AutoMapper to fulfil ITypeConverter<,> constructor dependecies with Autofac
My first time working with Autofac to inject AutoMapper's IMapper interface into classes that have an object mapping requirement. I have made some progress, with a little help, getting the various dependencies added to AutoMapper's register using…

Richard Slater
- 6,313
- 4
- 53
- 81
3
votes
1 answer
Automapper to update an existing object as opposed to creating a new one
Is there any way to use Automapper 5.1.1 to update an existing object as opposed to creating a new one.
For example we have a Customer entity and a CustomerViewModel. We would like to update an existing Customer with the CustomerViewModel field…

user2981411
- 859
- 12
- 34
3
votes
1 answer
How to resolve absolute url with automapper
I want to use automapper to create absolute url using Automappers profile. What is best practice of doing it?
My profiles are autoconfigured during startup.
I am using an Ioc Container if that might help.
SourceToDestinationProfile : Profile
{
…

Per
- 1,393
- 16
- 28
3
votes
1 answer
Empty property value after Automapper v5 upgrade
I have the below code that has been working in v3 of Automapper but no longer in v5. UPDATE It also works in v4.
CallScheduleProfile in its constructor sets a Title property to an instance of a class that passes a value of true to…

Jon
- 38,814
- 81
- 233
- 382
3
votes
1 answer
Using Automapper to Copy Properties from a Dynamic
I have a dynamic object (actually, a JObject, from JSON.NET) being built dynamically from JSON.
I want to have its properties copied to an existing object. The properties from the dynamic object should exist in the target object's type, if not, it's…

Ricardo Peres
- 13,724
- 5
- 57
- 74
2
votes
0 answers
AutoMapper inherintance with "new" modifier
I'm updating my project from AutoMapper version 4.2.1 to 6 and, in the new version, I get an unexpected behaviour.
Classes
class Opportunity : OpportunityLite
{
}
class OpportunityLite
{
public DealerOpportunityLite DealerOpportunity { get;…

Giacomo Baccianti
- 51
- 3