Questions tagged [automapper-3]

Use this tag for version specific questions about AutoMapper 3 - 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.

This release was focussed on a separation for platform deployments, code comments and LINQ projection. Release blog and notes give further details.

128 questions
74
votes
4 answers

Automapper: passing parameter to Map method

I'm using Automapper in a project and I need to dynamically valorize a field of my destination object. In my configuration I have something similar: cfg.CreateMap() // ... .ForMember(dest => dest.Timestamp, opt =>…
davioooh
  • 23,742
  • 39
  • 159
  • 250
42
votes
6 answers

How to configure Auto mapper in class library project?

I am using auto mapping first time. I am working on c# application and I want to use auto mapper. (I just want to know how to use it, so I don't have asp.net app neither MVC app.) I have three class library projects. I want to write transfer…
bnil
  • 1,531
  • 6
  • 35
  • 68
38
votes
5 answers

Automapper 3.0 - This type is not supported on this platform IMapperRegistry

I updated my project to use Automapper 3.0.0 and now my TFS build is not succeeding. The error is the following: "...System.PlatformNotSupportedException: System.PlatformNotSupportedException: This type is not supported on this platform…
nano
  • 439
  • 4
  • 7
21
votes
3 answers

AutoMapper.Mapper.CreateMap()' is obsolete

I have to classes Like class A { public int id {get; set;} } class B { public C c {get; set;} } class C { public int id {get; set;} public string Name {get; set;} } My requirement is to map id of class A to id of class C. Now what I was doing…
Sharad
  • 435
  • 1
  • 5
  • 18
12
votes
4 answers

Why won't AutoMapper v3 work because it's looking for v2.2.1.0?

I just installed AutoMapper, via nuGet, on a new project, but when I run the code, I get the following error: Could not load file or assembly 'AutoMapper, Version=2.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005' or one of its …
ProfK
  • 49,207
  • 121
  • 399
  • 775
10
votes
2 answers

Automapper and mapping list within a complex object / nested mappings

I am having a heck of a time converting from older mapping standards to automapper. Here are my classes // Models public class BaseModel { public Int64 Id { get; set; } public Guid UniqueId { get; set; } public DateTime? CreateDate {…
DRobertE
  • 3,478
  • 3
  • 26
  • 43
9
votes
1 answer

Automapper IEnumerable to IEnumerable without creating a map configuration

I cannot get the following to work, where array is an array of CustomerContract's: Mapper.Map>(array); Mapper.Map, IEnumerable>(array); Mapper.Map>(array); In my…
Bjørn
  • 1,138
  • 2
  • 16
  • 47
9
votes
2 answers

AutoMapper's Ignore() not working when using ForSourceMember?

I'm trying to ignore a property from source type. I have defined mapping like this: var map = AutoMapper.Mapper.CreateMap(); map.ForSourceMember(s => s.DateCreated, opt => opt.Ignore()); map.ForSourceMember(s => s.DateUpdated, opt…
khorvat
  • 1,630
  • 2
  • 20
  • 31
8
votes
1 answer

How to flatten a conditional object in a list in automapper

I have an Item that contains a list of Product's which are mapped to their respective ViewModel objects using AutoMapper. In my MVC project I have an Action method that displays an Item with a selected Product. For this i have a ViewModel called…
David
  • 15,150
  • 15
  • 61
  • 83
7
votes
1 answer

Is it possible to tell automapper to ignore mapping at runtime?

I'm using Entity Framework 6 and Automapper to map entities to dtos. I have this models public class PersonDto { public int Id { get; set; } public string Name { get; set; } public AddressDto Address { get; set; } } public class…
Reynaldi
  • 1,125
  • 2
  • 19
  • 41
7
votes
2 answers

Automapper, mapping single destination property as a concatenation of multiple source property

I have a situation where I need to map a single property as a combination of multiple source properties based on some conditions. Destination : public class Email { public Email() { EmailRecipient = new List(); } …
K Rajesh Kumar
  • 267
  • 3
  • 8
7
votes
2 answers

How to map to "this" with AutoMapper in constructor

I have a source type which have properties and a destination type which have exactly the same properties. After I configure one simple mapping for AutoMapper like: Mapper.CreateMap(); I would like to have a…
g.pickardou
  • 32,346
  • 36
  • 123
  • 268
7
votes
4 answers

AutoMapper TwoWay Mapping with same Property Name

Given these two objects public class UserModel { public string Name {get;set;} public IList Roles {get;set;} } public class UserViewModel { public string Name {get;set;} public IList Roles {get;set;} //…
Chase Florell
  • 46,378
  • 57
  • 186
  • 376
6
votes
2 answers

Automapper map one property to multiple

I am facing a challenge with AutoMapper between my source object and destination object. I will try to explain the sittuation. On my src object I have an string that according to its lenght it should be mapped to multiple properties of my…
JAVH
  • 155
  • 1
  • 3
  • 13
5
votes
2 answers

automapper error collection was modified when multiple users are creating a user

I am receiving following error and this error only comes up when multiple users are hitting the same button. Any help/ideas will be really appreciated: System.InvalidOperationException: Collection was modified; enumeration operation may not…
Baahubali
  • 4,604
  • 6
  • 33
  • 72
1
2 3
8 9