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 Model > ViewModel Mapping Exception
I have the following Models and ViewModels (edited for brevity):
public class Advert
{
public virtual long Id { get; set; }
public virtual string Title { get; set; }
public virtual string Descrip { get; set; }
public virtual…

marcusstarnes
- 6,393
- 14
- 65
- 112
1
vote
1 answer
How to avoid problems on Renaming Properties and Automapper
Suppose we have two c# classes A and B with the following properties
A
-Name
-SurName
B
-Name
-SurName
Using Automapper I can map from class A to class B without any problem.
What happened if I do a refactor to Class A -Name. Using VS2010…

user1040478
- 97
- 7
1
vote
1 answer
Automapper: Missing TypeMap configuration or unsupported mapping
// HomeController.cs
[AutoMap(typeof(Test), typeof(TestViewModel))]
public ActionResult Index()
{
var tests = new List();
tests.Add(new Test());
return View(tests);
}
// Index.cshtml
@model…

NVM
- 5,442
- 4
- 41
- 61
0
votes
1 answer
Large Entity and ViewModel Mapping
I have a very large entity with a few hundred properties. I have a repository that I use to select this all of the entities and returns an IEnumerable of the entity.
In my controller I then use automapper to map to an index ViewModel of this entity…

GraemeMiller
- 11,973
- 8
- 57
- 111
0
votes
0 answers
Using Automapper in .NET Core 3.1 for response resolvers
I am trying to migrate from the full .NET framework to .NET Core 3.1.
In .NET Framework, we are using Automapper v2.2.1 for mapping, so in .NET Core I'm also using Automapper 2.2.1 version.
This line is in one of Mapper files for getting…

sameera guntimadugu
- 39
- 3
0
votes
1 answer
AutoMap To Eliminate Join Table
Currently I have the following Objects that I need to map
OBJECT 1
public class ContactInfo
{
public int ContactInfoId { get; set; }
public ICollection Phones { get; set; }
}
public class PhoneToCustomer
{
public int…

Brandon Turpy
- 883
- 1
- 10
- 32
0
votes
0 answers
Automapper mapping collections at different level
I have Source Object which will be like below,
Class Employee
{
int EmpID { get; set; }
string EmpName { get; set; }
List AddressRelations { get; set; }
}
Class AddressRelation
{
int AddressRelationId { get; set; }
…

ps_prakash02
- 543
- 4
- 18
0
votes
1 answer
Automapper projection and union
I have a problem with union and automapper projections.
I have two entities:
public class Entity
{
public DateTime ActionDate { get; set; }
public int SomeProp { get; set; }
}
public class ExtendedEntity
{
public DateTime ActionDate {…

Anton Z
- 3
- 7
0
votes
2 answers
AutoMapper DataServiceCollection to List
I am attempted to use AutoMapper to map a DataServiceCollection to a list of strings and also create the reverse mapping. Any ideas on how to map a specialized collection like this to…

Adam
- 4,590
- 10
- 51
- 84
0
votes
2 answers
How do you merge two objects in AutoMapper?
Given the following:
public class NameValueContainer
{
public string Name { get; set; }
public IList Values { get; set; }
}
var first = new NameValueContainer
{
Name = "First",
Values = new List { "Value1", "Value2"…

Sebastian Patten
- 7,157
- 4
- 45
- 51
0
votes
1 answer
How to map properties of another class into parent class using automapper?
I am newbie for Automapper.
I have a domin and ViewModel class.
I want to map the domain class to ViewModel class.
Domain Class :
public class PurchaseOrder
{
public int Id { get; set; }
public string PONo { get; set; }
…

bnil
- 1,531
- 6
- 35
- 68
0
votes
1 answer
How to Map Three or N complex Objects to One Object using AutoMapper
I'm new to AutoMapper framework. I have three to Five complex objects which has to be mapped to one object
For example ChipInfo, HardDiskInfo, MonitorInfo, MemoryCardInfo has to be mapped to LaptopInfo because LaptopInfo object has fields that has…

AllSpark
- 425
- 1
- 4
- 17
0
votes
1 answer
Automapper options.ignore() does not work for lists
.ForMember(c = c.Property, options => options.Ignore()) works when you use a single object to map.
However, the ignore does not work in the case of lists.
For example see below code where destination List object already has some entries and when…

S2K
- 1,185
- 3
- 27
- 55
0
votes
1 answer
AutoMapper Map string to OptionSet value in MS Dynamics CRM
I am using AutoMapper.
My source object is simple class
public class Source
{
public string FirstName { get; set; }
public string type{ get; set; }
}
My destination is a MS Dynamics CRM Entity ( I have generated the model…

user2739679
- 827
- 4
- 14
- 24
0
votes
1 answer
AutoMapper error: class maps to a datatype (byte[])
I have two classes, each having a domain and a repo version.
DOMAIN:
public class MusicInfo
{
public string Id { get; set; }
public MusicImage Image { get; set; }
public MusicInfo(byte[] image)
{
this.Image = new…

raberana
- 11,739
- 18
- 69
- 95