Use this tag for version specific questions about AutoMapper 6 - 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-6]
117 questions
0
votes
2 answers
Automapper 6.0.2.0, Mapper.Map() throws StackOverflow when mapping Child Entities
Getting straight to the point, I've got the following Models:
public abstract class ControlData
{
public DateTime CreatedDate { get; set; }
public int CreatedById { get; set; }
[ForeignKey("CreatedById")]
public Collaborator…

Andy Dean Fox
- 11
- 5
0
votes
0 answers
Map properties by nameing convention
I am using automapper to map some objects between the database and another representation.
The entity looks something like
public class MyEntity {
public int Id { get; set; }
public Guid RowId { get; set; }
}
public class MyObject {
…

TGlatzer
- 5,815
- 2
- 25
- 46
0
votes
2 answers
Automapper 6.2.2 conditional unflattening?
I've recently updated to the latest version of Automapper (6.2.2) to take advantage of unflattening via .ReverseMap(). Everything seemed to be going well until I realized it was always creating an empty object regardless of whether or not the…
user999272
0
votes
1 answer
Mapping viewModel object to ICollection entity
I have a basic table with a few FK references. So when I retrieve an entity for an update operation; that entity contains ICollections of related entites. My main viewModel contains Lists which correspond to these ICollections. However, since some…

Shwrk
- 173
- 1
- 11
0
votes
1 answer
Reduce a list down to a field with runtime parameter
Is it possible to configure Automapper so it can map from a collection to a single instance based on a run-time parameter?
In our application our entities have labels for each language.
Depending on the preference of the current user, a single value…

Boris Callens
- 90,659
- 85
- 207
- 305
0
votes
2 answers
Error on initializing AutoMapper v6 in ASP.NET MVC App
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap();
});
config.AssertConfigurationIsValid();
var mapper = config.CreateMapper();
I am repeating these code in the project.…

Salomon Zhang
- 1,553
- 3
- 23
- 41
0
votes
1 answer
Automapper Issues with Profiles
Im using Autofac and Automapper, I have the following Domain classes:
public partial class Alumnos
{
public int Id { get; set; }
[Required]
[StringLength(50)]
public string Nombre { get; set; }
[Required]
…

Nickso
- 785
- 1
- 10
- 32
0
votes
1 answer
Lambda on AutoMapper Initialization Shows Warning as Function but Fine as Sub
I updated an AutoMapper V3.3.1 to V6.1.1 and much to my surprise, after putting all CreateMaps() in a profile, it actually worked perfectly right out of the gate – almost scary for me.
The problem that I am having is that it IS working with the code…

HumbleBeginnings
- 1,009
- 10
- 22
0
votes
1 answer
AutoMapping Entity to Model
I tried to map these but I am getting
AutoMapper.AutoMapperMappingException: 'Missing type map configuration
or unsupported mapping.'
public class MenuItemViewModel
{
[Required]
public string Text { get; set; }
public string URL {…

Mert
- 6,432
- 6
- 32
- 68
0
votes
1 answer
AutoMapper bi-directional mapping between first item in collection and single property
I'm using AutoMapper 6. Consider the following classes:
public class Source
{
public FlattenableClass Flattenable { get; set; }
public List EmailAddresses { get; set; }
}
public class Destination
{
public string…

xr280xr
- 12,621
- 7
- 81
- 125
0
votes
1 answer
Stop AutoMapper initializing data model properties during mapping
I have a ClientDocument data model and mapping as follows:
public class ClientDocument : BaseEntity
{
public int DocumentOwnerId { get; set; }
public int ClientProfileId { get; set; }
public virtual ClientProfile ClientProfile { get;…

lakeside
- 91
- 1
- 1
- 4
0
votes
2 answers
Automapper - exclude some objects from mapped collection
I have the following map rules:
CreateMap();
then I want to map ViewModels.ApplicationDriverFormVM to ApplicationDriverDomain, both are have Accidents property, which are…

Oleg Sh
- 8,496
- 17
- 89
- 159
0
votes
2 answers
Automapper configure 2 classes to one
I have the following DB (Infrastructure) classes:
[Table("ApplicationDriverEquipments")]
public partial class ApplicationDriverEquipment
{
public int Id { get; set; }
[StringLength(256)]
public string Make { get; set; }
…

Oleg Sh
- 8,496
- 17
- 89
- 159
0
votes
1 answer
Automapper not working in Reverse Mapping with NamingConvention
I’m using Automapper 6.1.1. and need to use reverse mapping. I found bug report from year 2004 and was closed. But in my example is not working, property c12 doesn't have value. So how could I use reverse mapping with this example?
public class…

kubo
- 492
- 7
- 19
0
votes
1 answer
Generic AutoMapper Mapping for all inheriting from a specific class
The majority of my view models inherit from a base view model called EncryptedBaseViewModel. This method encrypts the ID so the user does not see database sensitive information.
I would like to create an AutoMapper mapping that handles all mappings…

ᴍᴀᴛᴛ ʙᴀᴋᴇʀ
- 2,754
- 1
- 26
- 39