Use this tag for version specific questions about AutoMapper 2 - 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-2]
113 questions
1
vote
1 answer
AutoMapper for Custom Complex Types
I have Two Complex Types : One is into the Service Layer which serves as a ViewModel and other at the Repository Layer.
They are defined as given below :
//The Repository Layer
public class ProductDetailsEntity
{
public…

bhuvin
- 1,382
- 1
- 11
- 28
1
vote
2 answers
AutoMapper: Mapping child member from complex type to string[]
I have a destination type with a string[] property.
Animal
string[] Barks;
My source object is:
AnimalDTO
List Barks;
How do I map BarkTypes.NameOfBark to the string[] Barks?
Something like this:?
Mapper.CreateMap

Ian Vink
- 66,960
- 104
- 341
- 555
1
vote
1 answer
Use automapper to update destination object and set nullable type property value to null
It seems that nullable type properties in source is ignored and not copied to destination.
Consider these classes:
public class Source
{
public int? Test { get; set; }
}
public class Destination
{
public int? Test { get; set;…

mollwe
- 2,185
- 2
- 18
- 17
1
vote
0 answers
Bootstrapper.AutoMapper and Profile registration order
I'm working on an ASP.NET MVC 3 application using AutoMapper 2.2.0. I have some AutoMapper profiles declared and when I initialize them manually everything works just fine.
AutoMapper.Mapper.Initialize(x =>
{
…

peflorencio
- 2,284
- 2
- 32
- 40
1
vote
2 answers
How to make mapping between List and a string?
I have a Model an ViewModel Like this, but AutoMapper doesn't pass the values from MyViewModel to MyModel!
MyModel:
public List ContentLinks { get; set; }
public string ListOfContentLinks {
get
{
return String.Join(";",…

Omar AMEZOUG
- 958
- 2
- 14
- 38
1
vote
0 answers
How to map properly with Automapper?
I'm working on an application which uses Automapper, Unit Of Work, Entity Framework 5, ASPNET MVC 4, WebApi and Windsor Castle from Nuget.
I'm not sure if I should map this or it should be mapped by Automapper automatically
public…

polonskyg
- 4,269
- 9
- 41
- 93
1
vote
1 answer
AutoMapperMappingException Mapping types: Double -> Double
I am getting the following exception when I try to call Mapper.Map in my application:
AutoMapper.AutoMapperMappingException.
Mapping types:
Double -> Double
System.Double -> System.Double
Destination path:
Address.Latitude
Source…

SonOfPirate
- 5,642
- 3
- 41
- 97
1
vote
2 answers
Can AutoMappers AllowNullCollections setting be constrained to a profile?
Note: I have also asked this question on the AutoMapper mailing list
My MVC application essentially has two levels of mapping (simplified for this question):
RepositoryObject <-> Entity <-> ViewModel
We have created two profiles, each handling the…

Mightymuke
- 5,094
- 2
- 31
- 42
1
vote
2 answers
Automapper throws System.ArgumentException
I've updated AutoMapper to its version 2 and I've got a lot a problems with it now...
I've got a list of ItemToMap and all of these objects have got a reference to the same object Tag
When I try to map ItemToMap with ItemToMapDto, I've got this…

JiBéDoublevé
- 4,124
- 4
- 36
- 57
1
vote
1 answer
Convention for mapping collections to scalars via LINQ in Automapper
Automapper already does some nice convention stuff like mapping sub-properties by naming convention e.g. OrderTotal would map from Order.Total if such a property on a property existed.
I was wondering if there is a way to do a similar thing with…

Jack Ukleja
- 13,061
- 11
- 72
- 113
1
vote
3 answers
How to retrieve an Entity when using AutoMapper
I use MVC in Asp.net using AutoMapper.
As you can see from this code
Event eventObj = Mapper.Map(eventEditViewModel);
I'm trying to convert map EventEditViewModel to Event.
I would need need to use my Service layer to…

GibboK
- 71,848
- 143
- 435
- 658
1
vote
1 answer
AutoMapper mapping two concrete classes that share an interface
I have an interface that describes two objects. One is a DAO, the other is a BO. So, here's what it looks like:
public interface IOrder ...
public class OrderDAO : IOrder ...
public class OrderBO : IOrder ...
And I would like to map OrderDAO to…

Lao
- 151
- 1
- 8
1
vote
1 answer
AutoMapper map object to any inherited destination type
lets have an DTO class:
public class UserDto {
public int Id { get;set; }
}
And viewmodel class (base mvc project library):
public abstract class UserViewModelBase {
public int Id { get;set; }
}
now when i create mapping for automapper like…

psulek
- 4,308
- 3
- 29
- 37
1
vote
0 answers
Ninject and AutoMapper
I'm throwing together some code for an internal demo which consists of a Silverlight 5.0 UI built on Caliburn.Micro.
Summary Scenario:
I'm attempting to get AutoMapper to map a list of view models from a service proxy class. The view models have a…

6footunder
- 1,318
- 18
- 29
1
vote
2 answers
AutoMapper - Nested mapping whilst preserving selected child properties
So i have this;
public class Parent
{
public string SomeProperty { get; set; }
public Child ChildProperty { get; set; }
}
public class Child
{
public string ChildProperty { get; set; }
public string OtherChildProperty { get; set; }
}
public…

Stafford Williams
- 9,696
- 8
- 50
- 101