Reputation: 2043
I have a test which calls Mapper.ConfigurationProvider.AssertConfigurationIsValid();
I am getting a AutoMapperConfigurationException
when I try to map an IReadOnlyCollection
to a List
, but only the second time I try to do this.
I am on AutoMapper version 6.0.2. edit: I ran this on the latest version 6.1.1 and still got this error.
I have 4 classes.
FooRow
Foo
BarRow
Bar
I have the following mappings.
CreateMap<FooRow, Foo>
CreateMap<IReadOnlyCollection<FooRow>, List<Foo>>
CreateMap<BarRow, Bar>
CreateMap<IReadOnlyCollection<BarRow>, List<Bar>>
Only #4 fails. I am given the error Unmapped properties: Capacity
. Now, obviously for #4 I can add .ForMember(d => d.Capacity, o => o.Ignore)
however I am more interested in I must do this for the second mapping of Bar
but not Foo
.
Upvotes: 0
Views: 701
Reputation: 3122
It might be worth trying to remove the collection mappings, given that AutoMapper has built-in support for arrays and lists:
https://github.com/AutoMapper/AutoMapper/wiki/Lists-and-arrays
Upvotes: 2