Automapping a collection fails

1,052 views
Skip to first unread message

Thami Najim

unread,
Jan 20, 2022, 5:45:45 AM1/20/22
to AutoMapper-users
Hi there
I am hoping for some help with this bug.
I have a class that inherits from a List<T>. When setting the mapper-configuration I get an error:
System.ArgumentException: 'Incorrect number of arguments supplied for call to method 'AutoMapperPr.DestinationModel get_Item(Int32)' (Parameter 'property')'

Steps to reproduce:
Console application .Net 6 with AutoMapper v.11.0.0
Create these classes:
1. SourceModel
2. SourceModelCollection : List<SourceModel>
3. DestinationModel
4. DestionationModelCollection : List<DestionationModel>

Setup the automapper configuration:
var createMap = new MapperConfiguration
(
_config =>
{
_config.CreateMap<SourceModel, DestinationModel>().ReverseMap();
_config.CreateMap<SourceModelCollection, DestinationModelCollection>().ReverseMap();
}
);

Dennis Grass

unread,
Dec 1, 2022, 10:05:00 AM12/1/22
to AutoMapper-users
Hi @Thami,

have the same problem ... :/
Did you found a solution?

Best regards
Dennis

Maikol Martinez

unread,
Jan 23, 2023, 10:37:39 AM1/23/23
to AutoMapper-users
Hello, do you have the answer? I have the same problem? :(
Reply all
Reply to author
Forward
0 new messages