Use this tag for version specific questions about AutoMapper 4 - 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-4]
65 questions
1
vote
1 answer
AutoMapper with IDataReader to List always returns 0 counts
I am using latest version of AutoMapper in my application.
I want to convert DataTable object to List type,
I am using following code
Where reader is of type DataTable
Mapper.CreateMap>();
var response =…

Paresh Makwana
- 189
- 2
- 14
1
vote
1 answer
Automapper not mapped inside nested collection is not working properly
All. For example we have such simple classes
public class SimpleModel
{
public int PropertyId { get; set; }
public ICollection SimpleCollection { get; set; }
}
public class SimpleModelCollectionItem
{
public…

Alexey
- 11
- 1
- 3
0
votes
1 answer
How to pass arguments to a constructor of a base mapping profile?
I am currently migrating several mapping profiles from Automapper 4.2.1 to the latest version 9.0.0. The old mapping profiles are build up hierarchical, where the abstract base class requires an argument of type IDatetime. This injection is used for…

Matthias Güntert
- 4,013
- 6
- 41
- 89
0
votes
1 answer
Dotnet core automapper orderItems
Now I am creating a website where you can place orders.
There we have Order, OrderItem and Item.
public class Order
{
public int Id { get; set; }
public User User { get; set; }
public int? UserId { get; set; }
public…

Hassan Kalach
- 61
- 1
- 11
0
votes
2 answers
AutoMapper strange error
I'm using AutoMapper 4.1.1 within MVC 5 and then using it to map the entities from EF6 (pure Poco with any virtual and no lazy loading) to viewModels. I'm having an strange issue where AutoMapper is translating it correctly but in the other instance…

Johny
- 71
- 6
0
votes
1 answer
Automapper not ignoring properties with an error
We have a complex object User that contains a bunch of lists of other objects.
User
List Subordinates {get; set;}
etc....
When we run the code, it's quite acceptable for some of the properties to be in error because the connection to the…

griegs
- 22,624
- 33
- 128
- 205
0
votes
1 answer
automapper conversion from decimal to bool if not null
I am trying to convert from bool value to decimal i automapper. It works fine if i dont check for null values .But i want to check for null values and if the value is null ,let the value be null i destination else convert to decimal.Below is the ode…

user2465036
- 351
- 2
- 11
- 24
0
votes
0 answers
AutoMapper Mapper.Configuration.AssertConfigurationIsValid() passes but still runtime error
I am working on a ASP.NET MVC web app. I recently upgraded my AutoMapper references to 4.2.1 and am having all sorts of fits with it. It has now brought down my production application.
I fixed all errors returned as a result of…

crichavin
- 4,672
- 10
- 50
- 95
0
votes
1 answer
Using Automapper while using specification pattern to compose objects
A specification pattern can be used to compose objects as shown in the example below:
IUser user =
UserSpecification
.ForPerson()
.WithName("myname")
…

Satyajit
- 1,971
- 5
- 28
- 51
0
votes
1 answer
AutoMapper - complex mapping involving function call
I'm just getting to grips with AutoMapper and love how it works. However I believe it can map some complex scenarios that I'm currently wiring up manually. Does anyone have any suggestions / tips to remove my manual processes from the below…

Gavin
- 5,629
- 7
- 44
- 86
0
votes
1 answer
AutoMapper tries to map DbModel to dateTime
so here is mapping definition:
Mapper.CreateMap()
.ForAllMembers(options => options.ResolveUsing());
I have defined my custom resolver:
public class CustomMovieMapper :…

Hashem Aboonajmi
- 13,077
- 8
- 66
- 75
0
votes
1 answer
Automapper -AutoMapper.AutoMapperMappingException
I trying out Automapper, with a really easy mapping, but it does not work.
I am trying to map a System.Security.Claims.Claim type to another type ClaimItem:
public class ClaimItem
{
public string Type { get; set; }
public string Value { get;…

Legends
- 21,202
- 16
- 97
- 123
0
votes
1 answer
How to convert complex nested object hierarchy using Automapper
I have these following class under two different namespaces, e.g. Source and Target.
Mapping classes:
public class Instance
{
public Type Type { get; set; }
public object Definition { get; set; }
}
public sealed class Class : Instance
{
…

Furqan Safdar
- 16,260
- 13
- 59
- 93
0
votes
0 answers
Conversion from Simple Injector to Unity
How does this Simple Injector code translate to unity. This is with reference to this
public static Container RegisterAutoMapper(this Container container)
{
var profiles = typeof(AutoMapperRegistry).Assembly.GetTypes()
.Where(t =>…

xariez
- 529
- 1
- 5
- 17
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