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
2
votes
1 answer
AutoMapper - Map Json string property to interface based object
I have a source class like this:
public partial class Source
{
...
public int ScheduleBaseId { get; set; }
public int ScheduleIncrement { get; set; }
public int SubscriptionTypeId { get; set; } // <- Determines the concrete class to…

Gavin
- 5,629
- 7
- 44
- 86
2
votes
2 answers
How and where to implement automapper in WPF application
I haveBusinessLayer, DTO library,DataService, EntityModel(wher EDMX sits), DTO library refers to both business and data layer. I am trying to implement automapper in data layer, want to map entity object to DTO object and return DTO from the…

PRK
- 177
- 1
- 4
- 15
2
votes
1 answer
Avoid Duplicate CreateMap calls when using profiles?
We are using AutoMapper Profiles in order to keep our mappings decentralized. This works well, but we sometimes get some hard to debug issues when there are duplicate CreateMap calls. Is there a way to prevent this? This seems like it should be…

randomsolutions
- 2,075
- 1
- 19
- 22
2
votes
1 answer
Automapper and EF Navigation Properties
With ASP.NET MVC Core and Entity Framework Core I'm trying to create a simple website.
I've defined my Model:
public class Club
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public virtual IEnumerable…

Rhapsody
- 6,017
- 2
- 31
- 49
1
vote
1 answer
AutoMapper from DataTable to DTO
I have a DataSet populated during an ADO.NET call which I want to then use AutoMapper to convert to a DTO.
I have defined a generic-use mapper for many of our DTO types:
IMapper DataReaderMapper = new MapperConfiguration(cfg => {
…

Matt W
- 11,753
- 25
- 118
- 215
1
vote
0 answers
AutoMapper Map From Base Class Include Derived Class
Need some expert advice on this Automapper problem I'm trying to solve.
I have three classes, an entity, a base, and a derived class.
public class MyEntity
{
public string RefNumber {get;set;}
}
public class MyBaseClass
{
public string…

Tango Down
- 77
- 9
1
vote
1 answer
AutoMapper: map nested object to flat
I have defined a mapping from one type to DTO. Another type references the first type as an property, but the output should be an flattened DTO that should use the already defined mapping for the first type.
class Program {
static void…

Glumac
- 31
- 7
1
vote
1 answer
Want to select specific column through AutoMapper
Say we have a User entity with the following declaration:
public class User
{
public string About { get; set; }
public string FirstName { get; set; }
public int Id { get; set; }
public string LastName { get; set; }
public string ProfileImageUrl {…

AGH
- 353
- 1
- 14
1
vote
0 answers
Automapper re-map only a child object to existing flattened VM
I have a parent and child domain object being mapped to a single ViewModel object. E.G.
class Parent
{
public int ID {get;set;}
public string Name {get;set;}
public Child Child {get;set;}
}
class Child
{
public int ID {get; set;}
…

xr280xr
- 12,621
- 7
- 81
- 125
1
vote
1 answer
Automapper ProjectTo does not allow mapping properties to custom methods
I'm using Entity Framework 6.2.0 and Automapper 6.2.2. I need to map the entity Cart to CartDto. CartDto has a property Total which needs to be mapped to the result of Cart.GetTotal(). I'd like to use .ProjectTo to simplify the query, but if I do…

tocqueville
- 5,270
- 2
- 40
- 54
1
vote
0 answers
Automapper Flattening Common Nested Relationship
I'm trying to use Automapper to flatten a Entityframework object that has a nested complex property to a few various models that all inherit the same common properties from a base class, a simplified version of this is as follows:
public class…

user3564855
- 67
- 8
1
vote
1 answer
AutoMapper.Collections.EntityFramework
Asking same question differently!
Its seems clear I need to elaborate on this question because I have no viable responses.
Based on this AutoMapper registration code:
Mapper.Initialize(cfg =>
{
cfg.AddCollectionMappers();
…

tsage080667
- 89
- 1
- 10
1
vote
1 answer
ForAllOtherMembers exclude base properties
I'm mapping some properties of class A using AutoMapper 6.2.2, and for all other members, I'm ignoring them with code following:
expression.ForAllOtherMembers(f => f.Ignore());
This is what I want, but it ignores properties that are in the…

GuRAm
- 758
- 1
- 7
- 22
1
vote
1 answer
How to map a somewhat complex architecture with automapper and constructUsing
I have the following situation which I cannot get mapped properly:
I receive a list of following objects from a call to the camunda api.
public class CamundaTask
{
public string FormKey { get; set; }
public string Id { get; set; }
public…

Dimitris
- 155
- 1
- 11
1
vote
2 answers
AutoMapper .ReverseMap() .Ignore() not working
Having an issue with version 6.1.1. In the below, the result of the reverse map still has the Company object populated. Per this post, which shows what I am doing below, except they are ignoring a property, and I'm ignoring a complex object.
What…

crichavin
- 4,672
- 10
- 50
- 95