Questioning
Questioning

Reputation: 2043

AutoMapper throws AutoMapperConfigurationException for one mapping but not for another

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.

I have the following mappings.

  1. CreateMap<FooRow, Foo>
  2. CreateMap<IReadOnlyCollection<FooRow>, List<Foo>>
  3. CreateMap<BarRow, Bar>
  4. 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

Answers (1)

Hux
Hux

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

Related Questions