Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ResolutionContext.Items throwing exception from Automapper 9.0

Tags:

c#

automapper

I tried to upgrade my solution from Automapper V8.1.1 to Automapper V9.0.0 but I faced one issue.

I have two scenarios with one map. In the first scenario I pass data to the resolution context:

attachments = _mapper.Map<Attachment[]>(objects.Items, opt => {
            opt.Items[Constants.IncludeDescription] = true;
        });

and another where I do not:

attachments = _mapper.Map<Attachment[]>(objects.Items);`

Automapper V9.0.0:

enter image description here

Automapper V8.1.1: 2

Everything working fine for Automapper 8.1.1 but with version 9.0.0 context.Items throws a System.InvalidOperationException (see images above) so I am not sure if this is a bug or not.

like image 696
I need your help Avatar asked Apr 09 '26 15:04

I need your help


1 Answers

as @LucianBargaoanu noticed from 9.0.0 we need to provide _=>{} so resolutionContext.Items won't throw exception.

like image 85
I need your help Avatar answered Apr 12 '26 06:04

I need your help