Use this tag for version specific questions about AutoMapper 10 - 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. For general Automapper related questions use the [automapper] tag
Questions tagged [automapper-10]
38 questions
4
votes
1 answer
How can I convert from a byte[] to a string using AutoMapper?
I'm getting the following error in AutoMapper when trying to convert an object with a property that is of type byte[] to an object with a matching property of type string:
System.InvalidOperationException: Missing map from System.Byte to…

Brian
- 37,399
- 24
- 94
- 109
3
votes
0 answers
Upgrading Automapper and mapping zero to null based based on an attribute
I'm not very familiar with AutoMapper but am trying to update AutoMapper 4 to AutoMapper 10 (last version to support .Net Framework) on a project, and I have run into a problem: The ResolutionContext changed in the 4-5 upgrade so that it no longer…

jmoreno
- 12,752
- 4
- 60
- 91
3
votes
0 answers
How can I test a custom IValueResolver in AutoMapper 10?
AutoMapper 10 has removed the public constructor from the ResolutionContext class (https://docs.automapper.org/en/stable/10.0-Upgrade-Guide.html#the-resolutioncontext-no-longer-has-a-public-constructor). I have previously been creating an instance…

Joe Wirtley
- 456
- 4
- 9
2
votes
1 answer
How do I use AutoMapper to map via a constructor as well as resolving injected services
I am trying to use AutoMapper to map between two types where the destination type needs to be created from a constructor rather than a property mapping.
The complication is that whilst one of the construction parameters is a value I want to map from…

gouldos
- 1,015
- 1
- 16
- 30
1
vote
1 answer
How to prevent AutoMapper from overwriting existing values on destination object?
I have the following entities and corresponding view models
public class TopEntity
{
public int Id { get; set; }
public ICollection Bottoms { get; set; }
}
public class BottomEntity
{
public int Id { get; set; }
public int…

Gwinn
- 1,218
- 1
- 9
- 19
1
vote
0 answers
AutoMapper member-level transform not applied to destination value
Quick question about member-level value transformers. I have a string property mapped to a decimal property. I need to scale and round the destination value after it is mapped. I thought a value transformer would be the appropriate way to do…

Brian Engen
- 19
- 1
1
vote
0 answers
Extend current automapper instance with new mapper configurations
I am using AutoMapper 10.1.1 in my .net5 application.
In the startup of the project I have configured all my maps and then created mapper from the Mapper Configuration, something like:
var config = new MapperConfiguration(cfg => {
…

akshit
- 37
- 5
1
vote
1 answer
AutoMapper error mapping from an IEnumerable where T is an interface
I have a situation where I need to flatten a collection of items.
I set my Mapping profile like this:
CreateMap, IMySettingLookup>()
.ForMember(l => l.MySetting1,
o => o.MapFrom(sc =>
…

Nandun
- 1,802
- 2
- 20
- 35
1
vote
0 answers
AutoMapper 10.0 or AutoMapper.Data 5.0 now throws InvalidOperationException on AddDataReaderMapping Call
In bringing my project's AutoMapper version up from 3.1.1 to current 10.0 the last couple of days I had to add in AutoMapper.Data because I use it to map IDataRecord to a DTO and that feature was removed from AutoMapper with version 4.0. That code…

Mike K
- 1,313
- 2
- 18
- 28
1
vote
1 answer
Automapper - Make IncludeMembers() ignore null
IncludeMembers() will always map from first match even if object is null.
Let's say we have the following source models:
public class Item
{
public MovieMetadata MovieMetadata { get; set; }
public BookMetadata BookMetadata { get; set;…

Alex Volchetsky
- 87
- 8
1
vote
0 answers
Automapper Custom Resolve logic using Projection
I have an EF object Account that has 4 xrefs off for different portfolio types. For simplicity, I will call these types A, B, C, and D.
public class Account
{
public long AccountId { get; set; }
public PortfolioTypeAXref { get; set; }
…

Josh
- 16,286
- 25
- 113
- 158
1
vote
1 answer
Adding Default Constructor parameter to record using Automapper
Im trying to use automapper to map from one record to a new record and add a few defaults based on some logic.
I was originally expecting "ForCtorParam" to work, but im still getting the same exception after adding it.
public record Source(
…

Joao Vasconcelos
- 89
- 2
- 7
1
vote
2 answers
Manipulate the mapping expression of the profile of Automapper at runtime
I have some Automapper profiles, and I create two different mapper instances at runtime according to the situations. I need to ignore some members mapped inside these profiles at runtime for one of the mapper instances. Considering the example below…

Mahdi
- 119
- 2
- 11
1
vote
1 answer
WinForms c# application Upgrading From AutoMapper 9 to 10 issue
I have a large project that is using AutoMapper (currently version 9)
I tried to update to V10 but my code falls over and I don't understand what I need to change to resolve it
I have multiple objects that use a base class , the objects inherit this…

TruAG
- 41
- 4
0
votes
0 answers
Automapper is clearing my collections, despite use of Ignore; why?
I've been grappling with a bizarre Automapper behavior the last few days. My AutoMapper version is 10.1.1; at this time I do not have access to .NET Standard 2.1, so upgrading to 12.0.1 is not possible.
The relationship of the classes involved looks…

yvsean
- 9
- 2